I am using following technique to encrypt/decrypt password:
$key = 'abcd';
$password = 'password';
$encrypted_password = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $password, MCRYPT_MODE_CBC, md5(md5($key))));
$decrypted_password = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted_password), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
Above code is working for me on same page
But When I pass this encrypted password in URL to another webpage something like:
example.com/authenticate.php?pass=CuESFcvXHnQkZaY79WUL3U2aY9TROkjZFETk9Ur+iFY=
Then it is not decrypting it back in original form using same key and I am getting some garbage data as result.
I think it something like url encoding/decoding problem ?
Is there is any way to solve this?
Thanks