serpro / Android-PHP-Encrypt-Decrypt

Encrypt / Decrypt Between Android and PHP and vice-versa
155 stars 74 forks source link

Can not encrypt & decrypt JPG file #7

Closed poul-kg closed 10 years ago

poul-kg commented 10 years ago

I want to encrypt and then decrypt .jpg file

Here is the code snippet I use:

$crypter = new MCrypt();
// encrypt
file_put_contents('dst.ejp', $crypter->encrypt(file_get_contents('src.jpg')));
// decrypt
file_put_contents('dst-decrypted.jpg', $crypter->decrypt(file_get_contents('dst.ejp')));

but the final dst-decrypted.jpg is not a valid image file anymore.

Any suggestions? I'm using PHP 5.4.20