【问题标题】:Cryptography in NodeJs (SHA-1 ?)NodeJs 中的密码学 (SHA-1 ?)
【发布时间】:2017-12-18 06:31:42
【问题描述】:

我正在学习Node js,我不知道如何使用Cryptography 库(SHA-1?)。我如何在Node js 中使用SHA-1。这是伪代码:

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

【问题讨论】:

  • 这可能对你有帮助.. gist.github.com/thinkphp/5110833
  • 为了完整起见,请注意,出于加密目的,SHA-1 不应再被视为安全。使用其他哈希函数,例如 SHA-2 系列。

标签: node.js cryptography sha1


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-04-09
    • 2018-09-10
    • 1970-01-01
    • 2011-03-25
    • 2011-02-19
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 2017-08-05
    相关资源
    最近更新 更多