crypt.php
<?php
function decrypt($value)
{
$key = substr(sha1($_SERVER['REMOTE_ADDR']), 0, 6);
if(function_exists("mcrypt_ecb"))
{
return mcrypt_ecb(MCRYPT_BLOWFISH, $key, $value, MCRYPT_DECRYPT);
}
else return $value;
}
function encrypt($value)
{
$key = substr(sha1($_SERVER['REMOTE_ADDR']), 0, 6);
if(function_exists("mcrypt_ecb"))
{
return mcrypt_ecb(MCRYPT_BLOWFISH, $key, $value, MCRYPT_ENCRYPT);
}
else return $value;
}
?>
obscure.php
<?php
include("crypt.php");
$user_password = '0123456789abcdef';
print "input length: " . strlen($user_password) . "<br /><br />";# . encrypt($user_password) . "<br />";
$out = decrypt(encrypt($user_password));
print $out . "<br /><br />" . "output length: " . strlen($out);
?>
The output of obscure.php is
input length: 16
0123456789abcdef
output length: 16
- which is fine. But if the input isn't a multple of 8 (I think) I get random characters coming in... :eek:
($user_password = 0123456789abcdef0)
input length: 17
0123456789abcdef0�������
output length: 24
There should be 7 of these characters after 0123456789abcdef0: http://www.fileformat.info/info/unicode/char/fffd/index.htm
*** Oooh there are, they just don't show up, even as invisible, in the typing window.
For some reason if the input is not a multiple of 8, the output is rounded up with fffd chars.
Is this just my computer really not liking me, or did I do something wrong?
Thanks in advance!