Created
February 22, 2014 08:12
-
-
Save slopjong/9150366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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