I just use notepad, no hex editor.
<?php
// Cryptography Fuction
// Parameter: $string = The string that you want to encrypt / decrypt.
// Parameter: $key = encryption key.
// Parameter: $command = true to encrypt, false to decrypt.
// Returns: The encrypted / decrypted string;
function encryptDecrypt ($string, $key, $command) {
$algorithm = mcrypt_module_open('rijndael-256', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($algorithm), MCRYPT_RAND);
$key = substr($key, 0, mcrypt_enc_get_key_size($algorithm));
mcrypt_generic_init($algorithm, $key, $iv);
if($command) {
$string = trim($string);
$stringLength = strlen($string);
echo $stringLength; // JUST TO SHOW THE DIFFERENCE
$string = $stringLength . '|' .$string;
$encryptedData = mcrypt_generic($algorithm, $string);
} else {
$encryptedData = mdecrypt_generic($algorithm, $string);
list($stringLength, $paddedData) = explode('|', $encryptedData, 2);
$encryptedData = substr($paddedData, 0, $stringLength);
}
mcrypt_generic_deinit($algorithm);
mcrypt_module_close($algorithm);
return $encryptedData;
}
encryptDecrypt('hello world', $cryptKey, true); // Call function single quotes
encryptDecrypt("hello world", $cryptKey, true); // Call function double quotes
if (encryptDecrypt('hello world', $cryptKey, true) == encryptDecrypt("hello world", $cryptKey, true)) {
echo "Match";
} else {
echo "Dont Match";
}
?>
Output: 13 for single quotes
Output: 11 for double quotes
Output: Dont Match