The short answer is to use crypt
with salt starting with the characters $ 2a $ , a two-digit value parameter, $ and 22 digits from the alphabet ./0-9A-Za-Z . This only works on systems that support Blowfish encryption. However, PHP 5.3 implements it natively. See the PHP - crypt manual for more details.
Example:
crypt('rasmuslerdorf', '$2a$07$somesillystringforsalt')
The salt line starts the corresponding algorithm. The two-digit cost parameter is the logarithm of the base-2 iteration for the basic Blowfish-based hash algorithm and should be in the range [04 - 31]. Example 07 says that the algorithm uses 2 7 or 128 iterations. The higher this number, the more time it will take to execute BUT, in the context of hashing user passwords, i.e. GOOD .
This answer to a similar question explains in more detail what BCrypt is, how it relates to Blowfish and why you should use it. There are several others in the Stack Overflow section .
phpass is a great, easy-to-use password hashing system that works on all systems using Blowfish if it is supported, and return to other algorithms if it isn't.
source share