当前位置:操作系统 > 安卓/Android >>

Android中hmac用法

 

try {

 

 

String key = "1234567890", pass="pass";

SecretKeySpec sks = new SecretKeySpec(key.getBytes(), "hmacmd5");

Mac mac = Mac.getInstance("hmacmd5");

mac.init(sks);

mac.update(pass.getBytes());

byte[] result = mac.doFinal();

 

} catch (NoSuchAlgorithmException e) {

} catch (InvalidKeyException e) {

} catch (NumberFormatException e){

e.printStackTrace();

}

 

摘自cdzwm的专栏

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,