Skip to content

Instantly share code, notes, and snippets.

@henrytran9x
Created October 3, 2017 01:57
Show Gist options
  • Save henrytran9x/13075d0c5314e96b5a2085bcd405ad82 to your computer and use it in GitHub Desktop.
Save henrytran9x/13075d0c5314e96b5a2085bcd405ad82 to your computer and use it in GitHub Desktop.
encryptMD5
<?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