Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created November 19, 2012 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/4112366 to your computer and use it in GitHub Desktop.
Save ircmaxell/4112366 to your computer and use it in GitHub Desktop.
FUBAR password hashing implementation
<?php
if( ! function_exists('hash_password'))
{
function hash_password($password = NULL, $salt = NULL, $salt2)
{
if($password === NULL)
return FALSE;
if($salt === NULL)
$salt = config_item('encryption_key');
$password = (string) $password;
$salt = (string) $salt;
$ci =& get_instance();
$ci->load->library('encrypt');
$salt2 = $ci->encrypt->decode(base64_decode($salt2), config_item('encryption_key2'));
return crypt(hash_hmac('whirlpool', $password, hash('sha512', crypt($salt, '$6$rounds=100[000$' . hash('sha256', $salt)) . '$')), '$2y$12$'. $salt2 .'$');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment