I'm working on an application and I'm stuck here.
I'm making a product delete page, where the id is passed in the URL so that I can search the database and select the particular record. Since passing the id naked is not a good idea, so therefore I'm encrypting the id in a hash and then passing. But since the hash have some spaces in between, when I try to use it in my application..extra space characters are added in the hash to fill in the spaces.
Here's my encrypt function :-
function getHash($recordid)
{
global $db;
$key_value="12466X@@";
$plain_text=$recordid;
$encrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $plain_text, MCRYPT_ENCRYPT);
return $encrypted_text;
}
Here's what I get output for $plain_text = 1 when I do not pass in the URL and simply print it.
ÑÛo‡Ó‰-7
But, if I pass it via URL, it gets converted to this :-
%D1%DBo%87%D3%89-7
Therefore surely I wouldn't get the correct results when I decrypt it. Is there any way I can get the original value after decrypting it (1 in this example), or could I entirely use a different decrypt, encrypt function so that I get rid of this problem?
Thank you.