如何在Node Js中创建SHA512哈希...如何将此java代码转换为NodeJs

时间:2017-12-29 05:56:14

标签: javascript java node.js hash cryptojs

如何将此java转换为NodeJS

byte[] decodedKey = Hex.decodeHesecretKey.toCharArray());    
SecretKeySpec keySpec = new SecretKeySpec(decodedKey, algorithm);    
Mac mac = Mac.getInstance(algorithm);    
mac.init(keySpec);    
byte[] dataBytes = data.getBytes("UTF-8");    
byte[] signatureBytes = mac.doFinal(dataBytes);    
String signature = new String(Base64.encodeBase64(signatureBytes),"UTF-8"); 
return signature;

0 个答案:

没有答案