Skip to content

Instantly share code, notes, and snippets.

@Cycymomo
Created January 21, 2014 08:53
Show Gist options
  • Save Cycymomo/8536540 to your computer and use it in GitHub Desktop.
Save Cycymomo/8536540 to your computer and use it in GitHub Desktop.
twoWayEncryption.php
$key = 'password to (en/de)crypt';
$string = 'string to be encrypted';
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
var_dump($encrypted);
var_dump($decrypted);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment