首页
微信
安卓
接口
移动
前端
专题
文档库
工具
网址
§
ITPOW
>>
文档
>>
安卓开发
Android HMAC
作者:vkvi 来源:ITPOW
(原创)
日期:2017-4-3
以 HmacSHA1 为例:
public class HMACHelper { public static byte[] sha1(String text, String key) { try { byte[] textBytes = text.getBytes("UTF-8"); byte[] keyBytes = key.getBytes("UTF-8"); Mac mac = Mac.getInstance("HmacSHA1"); SecretKey secretKey = new SecretKeySpec(keyBytes, "HmacSHA1"); mac.init(secretKey); return mac.doFinal(textBytes); } catch (Exception e) { e.printStackTrace(); } return new byte[0]; } }
相关文章
创建于2005年
渝ICP备05010272号-1
电邮:
cftea@126.com
即将跳转...