3 ms·
Can someone explain to me what the "cost" option is?
by baby 13y ago
Can someone explain to me what the "cost" option is?
- Jeremy1026 13y agoThe cost option is how algorithmically complex the resulting hash will be. The greater the cost, the longer it takes to create the final hash, but the more secure it is. Lower cost = lower secure. Basically you want to use as high of a cost as you can on your servers hardware, without producing a noticeable slowdown to the end user.
- cabirum 13y agoIncreasing cost by 1 doubles the time needed to create a hash. A simple benchmark with results: http://pastebin.com/NiqKEAVm http://pastebin.com/NiqKEAVm
- mikeryan 13y agoOne reason why Bcrypt has taken over for other hashing algorithms is because it introduces a "work" factor which allows you to extend the amount of time it takes to calculate the hash in order to prevent brute force attacks. By making the work factor or "cost" adjustable you get some protection against Moore's law because as computers get faster you can up the "cost". Canonical article on why bcrypt which explains it here http://codahale.com/how-to-safely-store-a-password/ http://codahale.com/how-to-safely-store-a-password/