新建crypto.js
新建test.js
const crypto = require(‘./crypto’);
const secret = ‘abcdefg’;
const hash = crypto.createHmac(‘sha256’, secret);//加密格式sha256
.update(‘I love cupcakes’)
.digest(‘hex’);
console.log(hash); //加密功能
本文介绍了一个简单的JavaScript示例,演示了如何利用crypto.js库创建一个SHA256散列来加密字符串'Ilovecupcakes'。通过这个例子,读者可以了解基本的加密过程以及如何在实际项目中应用。
新建crypto.js
新建test.js
const crypto = require(‘./crypto’);
const secret = ‘abcdefg’;
const hash = crypto.createHmac(‘sha256’, secret);//加密格式sha256
.update(‘I love cupcakes’)
.digest(‘hex’);
console.log(hash); //加密功能
2580
2615

被折叠的 条评论
为什么被折叠?