Skip to content

Instantly share code, notes, and snippets.

@iarp
Created August 23, 2013 14:56
Show Gist options
  • Save iarp/6320284 to your computer and use it in GitHub Desktop.
Save iarp/6320284 to your computer and use it in GitHub Desktop.
Simple encrypt/decrypt functions.
<?php
function decryptRij($text) {
$salt = "my custom key";
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
function encryptRij($text) {
$salt = "my custom key";
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment