Vote count: 0
I have currently started to work with PHP with a Java background and came accross some issues. I am using mcrypt for a basic encryption using mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] )
the encryption works successfully but there is a case where I need to concatenate 2 strings and then encrypt them but when I do this the output is just as if I had encrypted each string separately then concatenated them afterwards and not before the encryption. What I am doing is this :
function encryptCode($data){
return mcrypt_encrypt( MCRYPT_DES , 'myKey' , $data , 'cbc' ,'myIV');
}
function decryptCode($data){
return mcrypt_decrypt( MCRYPT_DES , 'myKey' , $data , 'cbc' ,'myIV');
}
$decrypted = decryptCode('somePreviouslyEncryptedString');
$decrypted = $decrypted.'stringToAdd';
$encrypted = encryptCode($decrypted);
print_r($encrypted);
the output is then as if I had encrypted 'stringToAdd' seperately then added it to the previously encrypted string.
I am aware of the weakness of DES but I need it in this case so please no comments about that. Thanks to all for your help.
PHP mcrypt concatenate string crypts each string seperatly
Aucun commentaire:
Enregistrer un commentaire