在php中加密和解密word docx文件的问题 [英] Issue with encrypt and decrypt a word docx file in php
问题描述
我试图使用php mcrypt TripleDES加密 docx 格式文件。
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.
Office Open XML文件file_name无法打开,因为
内容有问题。 p>
The Office Open XML file file_name cannot be opened because there are problems with the contents.
以下代码
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;
}
任何帮助将不胜感激。
推荐答案
我一直在等待解决方案超过4个月。
最后我在google上找到了一些有价值的答案。现在我已经通过使用下面的链接修复了。
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:)
这篇关于在php中加密和解密word docx文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!