-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Hash by max time allotted #787 #887
base: master
Are you sure you want to change the base?
Conversation
return; | ||
} | ||
|
||
//since the relation b/w expected time and rounds roughly follows exptime = 2^(rounds-3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While working with the code, I observed that the time taken for each round was going exponential. When I analyzed the actual time taken with the help of following snippet.
var bcrypt=require('./bcrypt.js');
async function pass(){
for (let rounds = 1; rounds <= 20; rounds++){
var ini = new Date();
var hashpass = await bcrypt.hashSync("Blueisthecolorofsky", rounds);
var fin = new Date();
console.log(rounds,fin-ini);
}
}
pass();
and plotted the following graph with the help of Excel,
and compared it with the graph of 2^(rounds) with different proportionality constants k:
where it was observed to be very close with constant k=1/8, leading us to believe that time taken for each round closely follows the formula:
expected_time = (1/8) * 2^(number_of_rounds)
Thus it was concluded that:
number_of_rounds = log2(expected_time) + 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As processors go faster and architectures change, the k
value is going to change, the best tool is to benchmark on your server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know much about this, but couldn't a max time be set then it will do more rounds until time capped--with a minimum value? or is bcrypt not built like this
Feature implementation for defining work in terms of time and not rounds is done. The required task is performed by observing the graph between number of rounds and time taken. It is observed that the relationship almost follows below formula:
The files changed are readme.md and bcrypt.js