Skip to content

Instantly share code, notes, and snippets.

@slopjong
Created February 22, 2014 08:12
Show Gist options
  • Save slopjong/9150366 to your computer and use it in GitHub Desktop.
Save slopjong/9150366 to your computer and use it in GitHub Desktop.
<?php
function generateSecret()
{
$salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), "+", ".");
$shuffle = str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
$param = '$' . implode( '$', array("2y", 10, $salt) );
$blowfish = crypt($shuffle, $param);
return true;
}
$secret = generateSecret();
// now use $secret wherever you need high security
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment