tamamaxox
V2EX  ›  问与答

需要在每次加密的时候都要执行一次 crypto.createHash('md5')吗?

  •  
  •   tamamaxox · Jun 6, 2014 · 5894 views
    This topic created in 4407 days ago, the information mentioned may be changed or developed.
    还是只要在运行app时执行一次就好了
    为什么?
    2 replies    2014-06-06 14:40:41 +08:00
    mingzhi
        1
    mingzhi  
       Jun 6, 2014
    var md5 = crypto.createHash('md5')
    kfll
        2
    kfll  
       Jun 6, 2014 via Android   ❤️ 1
    http://nodejs.org/docs/latest/api/crypto.html#crypto_hash_digest_encoding

    Note: hash object can not be used after digest() method has been called

    所以你每次 digest 之后这个 hash 对象就没用了,下次使用需要重新创建
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4352 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 01:01 · PVG 09:01 · LAX 18:01 · JFK 21:01
    ♥ Do have faith in what you're doing.