Hi...
I am using the code above to use in url.
Example:
$code=public_encrypt("ref_123|bill@hotmail.com");
echo "<a href=http://mysite.com/contact/$code>support</a>";
$td = MCRYPT_RIJNDAEL_256;
$tdpub = MCRYPT_3DES;
$iv_size = mcrypt_get_iv_size($td, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
function public_encrypt($data){
global $tdpub, $iv_size, $iv;
$key="mykey";
$encrypted_data = mcrypt_encrypt($tdpub, $key, $data, MCRYPT_MODE_ECB, $iv);
$encrypted_data = bin2hex($encrypted_data);
return ($encrypted_data);
}
function public_decrypt($data){
global $tdpub, $iv_size, $iv;
$key="mykey";
$encrypted_data = hex2bin($data);
$decrypted_data = mcrypt_decrypt($tdpub, $key, $encrypted_data, MCRYPT_MODE_ECB, $iv);
return trim($decrypted_data);
}
PROBLEM:
I am getting a $code result in public_encrypt very large if emails are too long...
public_encrypt("ref_123|bill.gates.sucks@hotmail.com");
http://mysite.com/contact/b81470b62e92aa4966e59e4897f757a4c215a865aa7d85cd54520820168ad5312ef26f4176a4b5b5
Do you have any idea for a simple string encryption(+decrypt) function giving me a small result?
- it does not to be very strong.
- i thought in base64_encode/base64_decode but i have some problems with /+= chars received from base64_encode funciton...