素材牛VIP会员
bcrypt加密密码计算强度代表什么意思
 青***e  分类:Node.js  人气:734  回帖:1  发布于6年前 收藏

nodejs 中Bcrypt 在计算salt值时,计算强度为什么1-3 是一个阶段,4-10 是另外一个阶段。

var bcrypt = require('bcrypt-nodejs');

for (k=0;k<11;k++){

    timeout(k);
}

function timeout(round){
    console.log("round:"+round);
    var start = new Date();
    for(i=0;i<10;i++){
        var salt = bcrypt.genSaltSync(round);   
        var hash = bcrypt.hashSync('gebilaowang',salt);
        // console.log(hash);
    }

    var end = new Date();

    console.log(end-start+'ms');
}

1-3 的计算时间是1067ms ,和为10的值几本一样,但是4 才50ms,之后每次多一点一直到10,

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv3 码奴
起***劲 页面重构设计 6年前#1

https://github.com/shaneGirish/bcrypt-nodejs/blob/master/bCrypt.js#L54...

小于4轮是不好使的会默认变成10轮

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取