Created
September 16, 2011 13:47
-
-
Save justinkelly/1222159 to your computer and use it in GitHub Desktop.
Simple mcrypt encrypt & decrypt functions for PHP
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 | |
$salt ='whatever_you_want' | |
function simple_encrypt($text) | |
{ | |
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); | |
} | |
function simple_decrypt($text) | |
{ | |
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, i know, this gist is 6 years old, but i use this way too, is there a solution to migrate from mcrypt to openssl? mcrypt will be removed in php-7.2, so now i get with php-7.1 the deprecated messages. What i understand is, openssl does not support RIJNDAEL_256? So j have to reencrypt all files?