【发布时间】:2017-01-08 15:56:45
【问题描述】:
var crypto = require('crypto');
var key1 = crypto.createHash('md5').update('abcdefgh').digest();
var key2 = crypto.createHash('md5').update('abcdefgh').digest('base64');
var key3 = crypto.createHash('md5').update('abcdefgh').digest('hex');
var key4 = crypto.createHash('md5').update('abcdefgh').digest('latin1');
console.log('Key sizes :', key1.toString().length, key2.toString().length, key3.toString().length, key4.toString().length );
//Key sizes : 16 24 32 16
md5 不应该总是返回 16 字节的摘要吗?
【问题讨论】:
-
输出看起来不像MD5输出,看起来不是随机的,0xc2出现7次可能是console.log导致了意外输出。
标签: node.js encryption hash cryptography md5