I have been trying almost every example but nothing works. I am trying to read a cookie created by another script. The string in the cookie is encrypted using CBC, DES but yet my "salt" is 9 characters like ABCjg4ao1 as an example.
The string that I am receiving is either ASCII or hexcode like:
$string = "2616e646f6d495635e9afb9ab8ae93161018822157d8644bd68bdd3dfc938c350a507c645f04dcc38fd9bc435"; etc
How do I decrypt back to readable text? I have tried:
$encryptedstring = hex2bin($string);
$string = mcrypt_cbc(MCRYPT_DES, "ABCjg4ao1", $encryptedstring, MCRYPT_DECRYPT);
$string = decrypt_normal($string);
function decrypt_normal($salt, $c_t)
{
// incoming: should be the $key that you encrypted
// with and the $c_t (encrypted text)
// returns plain text
// decode it first :)
$c_t = trim(chop(base64_decode($c_t)));
/* generate an initialization vector */
$iv = substr(md5($salt), 0,mcrypt_get_iv_size (MCRYPT_DES,MCRYPT_MODE_CBC));
/* now we do our normal decrypting */
$p_t = mcrypt_decrypt (MCRYPT_DES, $salt, $c_t, "cbc", $iv);
return trim(chop($p_t));
}
But my string is still not readable and not decrypted.
any ideas?