Skip to content

Instantly share code, notes, and snippets.

@py7hon
Created June 23, 2018 12:21
Show Gist options
  • Save py7hon/625ca869d4b8ee67636ae55038fabae0 to your computer and use it in GitHub Desktop.
Save py7hon/625ca869d4b8ee67636ae55038fabae0 to your computer and use it in GitHub Desktop.
PHP MD5 Encryption and Decryption
<?php
$input = $_POST["pass"];
$encrypted = encryptIt( $input );
$decrypted = decryptIt( $encrypted );
echo $encrypted . '<br />' . $decrypted;
function encryptIt( $q ) {
$cryptKey = 'Kontolnee!!!';
$qEncoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $q, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
return( $qEncoded );
}
function decryptIt( $q ) {
$cryptKey = 'Kontolnee!!!';
$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