I\'m trying to achive the same DES encription that I\'ve in an C# code but in PHP.
The C# code looks like the following:
public static string Encript
Check your padding. PHP internally pads the data to be encrypted with binary NULLs \x00
by default which is definitively not the default padding mode in .NET (most likely they use PKCS7 padding by default).
Thank you very much guys. Helped me with same problem. PKCS7 padding here: How to add/remove PKCS7 padding from an AES encrypted string? just change ecb to cbc
here is a short snapshot i used:
$key = "29393651";
$iv = $key;
$pass_enc = $mypassword;
$block = mcrypt_get_block_size('des', 'cbc');
$pad = $block - (strlen($pass_enc) % $block);
$pass_enc .= str_repeat(chr($pad), $pad);
$pass_enc = mcrypt_encrypt(MCRYPT_DES, $key, $pass_enc, MCRYPT_MODE_CBC, $iv);
$pass_enc = base64_encode ($pass_enc);