Node v6 +中的某些输入所计算的哈希值与以前的Node版本不同。
基本上,当您
.update()使用v6之前的Node版本将字符串传递给时,默认编码为
binary,但对于Node v6则更改为
utf-8。
例如,使用以下代码:
require('crypto').createHash('md5').update('¥').digest('hex')这将
ab3af8566ddd20d7efc9b314abe90755在节点pre-6和
07625e142e4ac5961de57472657a88c1节点6上输出。
如果要让Node 6输出与6之前的版本相同的输出,则必须告诉
.update()您使用
binary编码:
require('crypto').createHash('md5').update('¥', 'binary').digest('hex')或相反(使Node pre-6的输出与6相同):
require('crypto').createHash('md5').update('¥', 'utf-8').digest('hex')


