• 请不要在回答技术问题时复制粘贴 AI 生成的内容
TomVista
V2EX  ›  程序员

有点懵逼,帮我看下代码,node.js crypto 模块

  •  
  •   TomVista · Nov 21, 2018 · 1902 views
    This topic created in 2777 days ago, the information mentioned may be changed or developed.

    code ``const crypto = require('crypto');

    var hash = crypto.createHash('sha1','123').digest('hex'); console.log(hash);

    var hash2 = crypto.createHash('sha1'); hash2.update('123'); console.log(hash2.digest('hex'))``

    这个得到的两个结果不一样,为啥? 下面的应该是正确的.

    devqin
        1
    devqin  
       Nov 21, 2018   ❤️ 1
    createHash 第二个参数并不是要加密的数据呢。
    TomVista
        2
    TomVista  
    OP
       Nov 21, 2018
    @devqin 哈? (╯‵□′)╯︵┻━┻ 看来英文文档确实是不能猜
    daizongxyz
        3
    daizongxyz  
       Nov 21, 2018   ❤️ 1
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   914 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:53 · PVG 04:53 · LAX 13:53 · JFK 16:53
    ♥ Do have faith in what you're doing.