Skip to content

Instantly share code, notes, and snippets.

@VasilSlavchev
Forked from oropesa/encrypt-decrypt.php
Created October 13, 2020 00:56
Show Gist options
  • Save VasilSlavchev/57f2492be92997d2ce42912797e74714 to your computer and use it in GitHub Desktop.
Save VasilSlavchev/57f2492be92997d2ce42912797e74714 to your computer and use it in GitHub Desktop.
Encrypt and decrypt md5 in php
$input = "SmackFactory";
$encrypted = encryptIt( $input );
$decrypted = decryptIt( $encrypted );
echo $encrypted . '<br />' . $decrypted;
function encryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );
}
function decryptIt( $q ) {
$cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
$qDecoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $q ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
return( $qDecoded );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment