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();
}

你可能感兴趣的:(Android中hmac用法)