Traditional encryption methods:
MD5 (password + salt value);
$passwordString = ' your password ';//Your password $salt= "your salt value";//salt, increase complexity (random string) $md 5password=md5 ($passwordString. $ SALT);
Theoretically speaking, MD5 is not reversible, which is a more secure encryption method. But I would like to remind that MD5 early in 04 was the Chinese cracked (please search the Shandong University Xiao). Once dragged into the library, the likelihood of a password leak is great.
A new approach is now recommended: password hashing algorithm functions
password_get_info-returns information about the specified hash (hash)
password_hash-creating a hash of the password (hash)
Password_needs_rehash-checks if the given hash matches the given options
password_verify-Verify that the password matches the hash
PHP5.5 introduces the password hashing function, the kernel comes with no need to install extensions. It is also possible to test under PHP5.4, before using it, it is best to confirm whether your current environment supports these functions.
Password hashing mainly provides 4 functions
View information about the hash value array Password_get_info (string $hash)//Create a hash password string Password_hash (string $password, Integer $algo [, Array $options])//Determine if the hash password is a specific option, the algorithm creates a Boolean Password_needs_rehash (String $hash, Integer $algo [, array $options] Boo Lean password_verify (String $password, String $hash)//Authentication password
Code Demo:
$password = ' password123456 ';//original password//use BCRYPT algorithm to encrypt password $hash_password = Password_hash ($password, Password_bcrypt); if ( Password_verify ($password, $hash _password)) {echo "Password match";} else{echo "Password Error";}
Important Features:
By Password_hash encrypted passwords, it is difficult to hack using a dictionary because each generated password is not the same. This encryption can only be cracked by brute force.
Last reminder:
Encryption method is good, the original password settings are too simple to be cracked, set a complex password is kingly.
This article is from the "My PHP path" blog, so be sure to keep this source http://phpme.blog.51cto.com/663593/1926557
PHP is more secure than MD5 encryption method--hash password