V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
TomVista
V2EX  ›  程序员

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

  •  
  •   TomVista · 2018 年 11 月 21 日 · 1680 次点击
    这是一个创建于 2610 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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  
       2018 年 11 月 21 日   ❤️ 1
    createHash 第二个参数并不是要加密的数据呢。
    TomVista
        2
    TomVista  
    OP
       2018 年 11 月 21 日
    @devqin 哈? (╯‵□′)╯︵┻━┻ 看来英文文档确实是不能猜
    daizongxyz
        3
    daizongxyz  
       2018 年 11 月 21 日   ❤️ 1
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3000 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 14:37 · PVG 22:37 · LAX 06:37 · JFK 09:37
    ♥ Do have faith in what you're doing.