Hashing a Value

Problem

You want to create a hash of a string.

Solution

Use the Hash::make() method.

$hashed_password = Hash::make($plaintext_password);

Discussion

Hashing uses the Blowfish algorithm.

See The bcrypt Wikipedia article.

You can also specify the cost parameter for hashing. This is a base-2 logarithm of the times the hashing routine is iterated.

$hashed = Hash::make($plaintext, array('rounds' => 10));

This will change the the cost parameter from the default of 8 to 10.

comments powered by Disqus