Skip to content

Instantly share code, notes, and snippets.

@ianthrive
Created February 19, 2013 11:33
Show Gist options
  • Save ianthrive/4985057 to your computer and use it in GitHub Desktop.
Save ianthrive/4985057 to your computer and use it in GitHub Desktop.
<?php
function bcrypt($input, $salt=null, $rounds=12) {
if($rounds < 4 || $rounds > 31) $rounds = 12;
if(is_null($salt)) $salt = sprintf('$2a$%02d$', $rounds).substr(str_replace('+', '.', base64_encode(pack('N4', mt_rand(), mt_rand(), mt_rand(), mt_rand()))), 0, 22);
return crypt($input, $salt);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment