fan*_*ncy 53 cryptography bcrypt node.js
有人可以指出两者之间的差异以及使用每种情况的示例情况吗?
bcrypt看起来很棒.
Mik*_*ott 69
使用bcrypt你想要进行缓慢且计算成本高昂的散列 - 这通常适用于你真的不希望攻击者能够反转散列的哈希,例如用户密码.使用本机加密来完成其他任务.
Igo*_*rra 19
与@ mike-scott的答案一致,你应该更喜欢bcrypt
与密码相关的东西,但你仍然可以crypto
用于各种任务,如创建随机令牌或HMAC校验和或SHA1/MD5哈希:
var crypto = require('crypto');
// random tokens
var buf = crypto.randomBytes(16).toString('hex');
console.log('Random token of %d bytes in hexadecimal: %s', buf.length, buf);
var buf = crypto.randomBytes(16).toString('base64');
console.log('Random token of %d bytes in base 64: %s', buf.length, buf);
// a hashed message authentication checksum (HMAC) using a shared secret key
var string = 'My coffee please';
var key = 'Right away sir';
var encrypted = crypto.createHmac('sha1', key).update(string).digest('hex');
console.log('Encrypting "%s" using passphrase "%s": %s', string, key, encrypted);
// a MD5 hash
var hashmd5 = crypto.createHash('md5').update(string).digest('hex');
console.log('The MD5 hash of "%s" is %s', string, hashmd5);
// a SHA1 hash
var hashsha1 = crypto.createHash('sha1').update(string).digest('hex');
console.log('The SHA1 hash of "%s" is %s', string, hashsha1);
Run Code Online (Sandbox Code Playgroud)
Bas*_*sav 17
我会使用 nodejs 的原生加密库
我认为决定不应该仅仅基于谁做得更好,它远不止于此
您应该知道为什么 node.js 包含一个用于加密的内置模块,而它最初不是 node.js 的一部分,并且许多库在 npm 存储库中很受欢迎,包括 bcrypt
原因是,密码学是一个重要的安全方面,使用来自 npm 的外部模块有可能注入恶意代码,这违背了最初的安全目标
因此需要一个受信任的库来实现这种加密功能,这也是 nodejs 提供这样一个库的动机
如果您认为加密方法不强,最好在 nodejs 上提出相同的问题,而不是盲目信任外部库
还是不相信我?阅读这篇文章https://hackernoon.com/im-harvesting-credit-card-numbers-and-passwords-from-your-site-here-s-how-9a8cb347c5b5
归档时间: |
|
查看次数: |
21393 次 |
最近记录: |