Skip to content

Instantly share code, notes, and snippets.

@aswebdev
Created October 30, 2013 23:14
Show Gist options
  • Save aswebdev/aa80139dba172c3e8949 to your computer and use it in GitHub Desktop.
Save aswebdev/aa80139dba172c3e8949 to your computer and use it in GitHub Desktop.
Functions for securely encrypting data with Salt
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