Created
October 30, 2013 23:14
-
-
Save aswebdev/aa80139dba172c3e8949 to your computer and use it in GitHub Desktop.
Functions for securely encrypting data with Salt
This file contains hidden or 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
function encrypt($key,$string) { | |
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); | |
} | |
function decrypt($key,$encrypted) { | |
return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment