function encrypt_SO($str, $key) {
//$ivsize = mcrypt_get_iv_size(MCRYPT_DES, MCRYPT_MODE_CBC);
//$blocksize = mcrypt_get_block_size(MCRYPT_DES, MCRYPT_MODE_CBC);
$keysize = mcrypt_get_key_size(MCRYPT_DES, MCRYPT_MODE_CBC);
// Need to use the SAME IV as the Delphi function. By default
// this is (0,0,0,0,0,0,0,0) encrypted using ECB mode and gives the
// following bytes:
$ivbytes = array(72, 163, 99, 62, 219, 111, 163, 114);
$iv = implode(array_map("chr", $ivbytes));
$enc = base64_encode($str); // aenderung hier: _ENcode
$k = mhash(MHASH_SHA1, $key);
$
dec = mcrypt_encrypt(MCRYPT_DES, substr($k, 0, $keysize), $enc, MCRYPT_MODE_CBC, $iv); // aenderung hier: _ENcrypt
$pad = ord($
dec[strlen($
dec) - 1]);
return substr($
dec, 0, strlen($
dec) - $pad);
}
$
dec = 'this is a test';
$enc = encrypt_SO($
dec, 'test');
echo "$enc\n";