We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const crypto = require("crypto");
var algorithm="sm3"; var message="aaa"; var secret="123";
var args = process.argv; if (args.length>2) message=args[2]; if (args.length>3) algorithm=args[3]; if (args.length>4) secret=args[4];
var hash = crypto.createHmac(algorithm,secret);
hash.update(message); console.log("Message:\t",message); console.log("Secret:\t\t",secret); console.log("Method:\t\t",algorithm); var myhash = hash.digest('hex'); console.log("\nHMAC is:\t",myhash); hash = crypto.createHash(algorithm); console.log("HMAC is:\t",hash.digest('base64'));
console.log("\nLength of HMAC: ",myhash.length*4," bits");
//crypto 算出来的结果和C运行结果一致
The text was updated successfully, but these errors were encountered:
const sm3 = require('sm-crypto').sm3 let hashData = sm3('abc') // 杂凑 // hmac hashData = sm3('abc', { key: 'daac25c1512fe50f79b0e4526b93f5c0e1460cef40b6dd44af13caec62e8c60e0d885f3c6d6fb51e530889e6fd4ac743a6d332e68a0f2a3923f42585dceb93e9', // 要求为 16 进制串或字节数组 })
其中key要求是16进制hex格式的字符串,也就是说一个字节必须用2个字符表示,例如00~FF,123不是一个有效的hex字符串。
123
是否可以提交hex格式字符串示例数据,或者提供example 示例。
Sorry, something went wrong.
No branches or pull requests
const crypto = require("crypto");
var algorithm="sm3";
var message="aaa";
var secret="123";
var args = process.argv;
if (args.length>2) message=args[2];
if (args.length>3) algorithm=args[3];
if (args.length>4) secret=args[4];
var hash = crypto.createHmac(algorithm,secret);
hash.update(message);
console.log("Message:\t",message);
console.log("Secret:\t\t",secret);
console.log("Method:\t\t",algorithm);
var myhash = hash.digest('hex');
console.log("\nHMAC is:\t",myhash);
hash = crypto.createHash(algorithm);
console.log("HMAC is:\t",hash.digest('base64'));
console.log("\nLength of HMAC: ",myhash.length*4," bits");
//crypto 算出来的结果和C运行结果一致
The text was updated successfully, but these errors were encountered: