Is it possible to specify a lowercase only output when using Mcrypt?
This is a sample of my code used to encrypt:
public function encode($value){
if(!$value){return false;}
$text = $value;
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv);
return trim($this->safe_b64encode($crypttext));
}
The reason for this is that I need a lowercase only encrypted string.
Thank you,
Chris.
EDIT
I am creating a reply via email app that lets users reply to a thread via the notification email. I am using a unique encrypted string as the reply email to identify it. Mcrypt outputs upper and lowercase strings. This works fine for Gmail and Outlook, but Hotmail converts the reply address string to lowercase which then errors when I decrypt. I therefore need the output string from the func above to be lowercase only.
You can't make mcrypt_encrypt
give you all lowercase output, but you can avoid uppercase letters in the email address you send out. Either find 26 other characters not already used in mcrypt's output (probably won't be able to find that many) to replace upper case letters with, or just lowercase each letter, placing some sort of marker character before or after them so you can convert them back to uppercase before passing to mcrypt_decrypt
.
For example, you could make 97Ahff4DYAH9fh9f
into 97_ahff4_d_y_a_h9fh9f
. Converting between the two forms should be relatively easing using regular expressions.