Saturday, 28 September 2013

Encryption routine adds %3D to the end of ouput

Encryption routine adds %3D to the end of ouput

I have an encryption that I use for some minor security but I am noticing
that the out always seems to have %3D at the end of the encrypted string
and I am not sure why.
private static function encrypt($str, $key)
{
$result = null;
for ($i = 0; $i < strlen($str); $i++) {
$char = substr($str, $i, 1);
$keyChar = substr($key, ($i % strlen($key)) - 1, 1);
$char = chr(ord($char) + ord($keyChar));
$result .= $char;
}
return urlencode(base64_encode($result));
}
I cannot see anything glaring in there.
When decrypting the strings there are no errors when I manually remove the
extra %3D at the end of the string.
so
bnNMTXc0Sjc%3D
AND
bnNMTXc0Sjc
Will both decrypt the same. I just want to clean up the encrypted strings
to not have the extra chars at end.
Thanks

No comments:

Post a Comment