问题
I tried to use php mcrypt TripleDES for encryption for docx format files.
When i tried to decrypt the file, i am getting the error as follows.
The Office Open XML file file_name cannot be opened because there are problems with the contents.
Here is the below code
function Encrypt($source,$key,$iv) {
$cipher = mcrypt_module_open(MCRYPT_3DES, '', 'cbc', '');
mcrypt_generic_init($cipher, $key, $iv);
$result = mcrypt_generic($cipher, $source);
mcrypt_generic_deinit($cipher);
return $result;
}
function Decrypt($source,$key,$iv) {
$cipher = mcrypt_module_open(MCRYPT_3DES, '', 'cbc', '');
mcrypt_generic_init($cipher, $key, $iv);
$result = mdecrypt_generic($cipher, $source);
mcrypt_generic_deinit($cipher);
return $result;
}
Any help will be appreciated.
回答1:
I have been waiting for the solution more than 4 months. Finally i found some valuable answer in google. Now i have fixed it by using below link.
http://www.howwhywhat.in/how-to-implement-common-file-encryption-and-decryption-between-c-and-php/
Best part is ,it has live examples too:)
来源:https://stackoverflow.com/questions/10548386/issue-with-encrypt-and-decrypt-a-word-docx-file-in-php