Friday, September 25, 2009

Decode Some String (forget why I wrote this)


function DecodePassword(&$text)
{
$pwdutf8 = $text;
$pwd = base64_decode($pwdutf8);
RotateBitLeft($pwd);
$text = $pwd;

return true;
}

function RotateBitLeft(&$str)
{
$cstr = str_split($str);
for($count = 0; $count < count($cstr); $count++)
$cstr[$count] = chr((ord($cstr[$count]) << (1)) | (ord($cstr[$count]) >> (8-(1))));
$str = implode($cstr);

return;
}

function UnitTest()
{
$string = 'MrI7HBUkt7q5sg==';
DecodePassword($string);
echo "$string\n";
}

UnitTest();