如何在Node Js中生成hmacsha512

时间:2017-12-28 12:16:33

标签: javascript java node.js

var crypto = require('crypto');   
var output = encrypt(key,str); 
function encrypt(key, str){    
  var hmac = crypto.createHmac("sha512", key);   
  var signed = hmac.update(new Buffer(str, 'utf-8')).digest("base64");
  return signed
}

这里我没有得到正确的输出作为

中的相同输出
Java.byte[] decodedKey =  Hex.decodeHesecretKey.toCharArray());
SecretKeySpec keySpec = new SecretKeySpec(decodedKey, algorithm);
Mac mac = Mac.getInstance(algorithm);    
mac.init(keySpec);

0 个答案:

没有答案