Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function process_password($password, $salt = '') {
- /**
- * Process a password to encrypt it for storage or verification.
- * @param string - plain text password for processing.
- * @access private
- * @return array Containing the encrypted password and the salt.
- */
- //Check if the salt has been supplied. If not, generate one.
- if ($salt && strlen($salt) !== 64) {
- log_message('info', 'Supplied password to process_password() was not the correct 64-byte length.');
- return false;
- }
- $salt = bin2hex(mcrypt_create_iv(32, MCRYPT_DEV_URANDOM));
- $hashed_password = hash('sha256', $password . $salt);
- return array('password' => $hashed_password, 'salt' => $salt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement