ok i found this:
http://www.ficgs.com/How-to-crypt-an...ypt-s3141.html
and base64_encode and base64_decode does exist in PHP as in c.
Now i have to translate this to php and figure out how to handle the keys for different versions etc.
Happy programming!
How to crypt and decrypt ?
Every programmer at least once look for a good way to encrypt with the possibility to decrypt. Md5 and Sha1 are not convenient in this case as it is not possible to decrypt with these functions.
Here are nice functions that will help you to encrypt and decrypt with a key :
<?
function encrypt($string, $key)
{
$string = 'STT576PWZA'.$string;
$result = '';
for($i=0; $i<strlen($string); $i++)
{
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result.=$char;
}
return base64_encode($result);
}
function decrypt($string, $key)
{
$result = '';
$string = base64_decode($string);
for($i=0; $i<strlen($string); $i++)
{
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)-ord($keychar));
$result.=$char;
}
$result = substr($result,10,strlen($result));
return $result;
}
?>
Note that here the string to encrypt is added to 10 characters, this may not be useful but it is just a way to add kind of salt.
It works fine anyway !