function encryptAndEncode($strIn) { global $strEncryptionType, $strEncryptionPassword; //** XOR encryption with Base64 encoding ** // return base64Encode(simpleXor($strIn,$strEncryptionPassword)); //** AES encryption, CBC blocking with PKCS5 padding then HEX encoding - DEFAULT ** //** use initialization vector (IV) set from $strEncryptionPassword $strIV = $strEncryptionPassword; //** add PKCS5 padding to the text to be encypted $strIn = addPKCS5Padding($strIn); //** perform encryption with PHP's MCRYPT module $strCrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $strEncryptionPassword, $strIn, MCRYPT_MODE_CBC, $strIV); //** perform hex encoding and return return "@" . bin2hex($strCrypt); }
function encryptAes($string, $key) { // AES encryption, CBC blocking with PKCS5 padding then HEX encoding. // Add PKCS5 padding to the text to be encypted. $string = addPKCS5Padding($string); // Perform encryption with PHP's MCRYPT module. $crypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $string, MCRYPT_MODE_CBC, $key); // Perform hex encoding and return. return "@" . strtoupper(bin2hex($crypt)); }