Cryptography in NodeJs (SHA-1 ?)

时间:2017-12-18 06:31:42

标签: node.js cryptography sha1

I am learning about Node js, I don't know how to use a Cryptography libary (SHA-1 ?). How can I use SHA-1 in Node js. Here is pseudo code:

// Use a Base64-encoder that don't introduce line-breaks, 
// or trim the output signature afterwards.
string signature = Base64.encode(SHA1.digest(stringToSign));

1 个答案:

答案 0 :(得分:0)

Node.js为您提供加密模块。

const crypto = require('crypto');
crypto.createHash('sha1').update(stringToSign).digest('base64');