Created
October 3, 2017 01:57
-
-
Save henrytran9x/13075d0c5314e96b5a2085bcd405ad82 to your computer and use it in GitHub Desktop.
encryptMD5
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
<?php | |
/* | |
* Function create encrypt MD5 | |
* Remember mcrypt_encrypt() not support PHP 7.0 | |
*/ | |
public function encryptMD5($string) { | |
$qEncoded = base64_encode(mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5('[MÃ_KEY]'), $string, MCRYPT_MODE_CBC, md5( md5(['[MÃ_KEY]']) ) ) ); | |
return $qEncoded; | |
} | |
/* | |
* Function create decrypt MD5 | |
* Remember mcrypt_encrypt() not support PHP 7.0 | |
*/ | |
public function decryptMD5($string) { | |
//Find whitespace and replace to '+' | |
$string = preg_replace('/\s+/','+',$string); | |
$qDecoded = rtrim(mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5('[MÃ_KEY]'), base64_decode($string), MCRYPT_MODE_CBC, md5( md5(['[MÃ_KEY]']) ) ), "\0"); | |
return $qDecoded; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment