V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
TomVista
V2EX  ›  程序员

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

  •  
  •   TomVista · 2018-11-21 12:38:09 +08:00 · 1233 次点击
    这是一个创建于 1954 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 14:30:51 +08:00   ❤️ 1
    createHash 第二个参数并不是要加密的数据呢。
    TomVista
        2
    TomVista  
    OP
       2018-11-21 14:55:44 +08:00
    @devqin 哈? (╯‵□′)╯︵┻━┻ 看来英文文档确实是不能猜
    daizongxyz
        3
    daizongxyz  
       2018-11-21 16:30:52 +08:00   ❤️ 1
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2535 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:58 · PVG 23:58 · LAX 08:58 · JFK 11:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.