简体   繁体   English

使用openssl命令在php服务器上解密文件

[英]Decryption of a file on php server using openssl commands

I am encrypting a file on client side and trying to decrypt it on my linux server using openssl command, its creating output file but with 0 bytes size. 我正在客户端加密文件,并尝试使用openssl命令在我的linux服务器上对其解密,该文件创建输出文件,但大小为0字节。

The code I am using in php for decrypting file is: 我在php中用于解密文件的代码是:

system("openssl enc -d -aes-192-ecb -in secure.cxf -out plain.xml -K 11223344556677889900aabbccddeeff0011223344556677");

here I am using AES in ECB mode with 192 bit (24 byte) key, 我在ECB模式下使用192位(24字节)密钥的AES,

where 哪里

secure.cxf is input file in same folder with php file secure.cxf是与php文件位于同一文件夹中的输入文件

plain.xml is output file comes with 0 bytes plain.xml是带有0字节的输出文件

11223344556677889900aabbccddeeff0011223344556677 is my private key of decryption 11223344556677889900aabbccddeeff0011223344556677是我的解密私钥

I have tried the same openssl command on different linux operationg systems, the command works fine but on server it makes empty output file. 我已经在不同的Linux操作系统上尝试过相同的openssl命令,该命令可以正常工作,但是在服务器上它会生成空的输出文件。 Any idea how to resolve the empty file problem? 任何想法如何解决空文件问题? Is there any alternative way to do same decryption (AES, ECB mode, 192 bit key) for files on php server? 有没有其他方法可以对php服务器上的文件执行相同的解密(AES,ECB模式,192位密钥)?

Thanks in advance. 提前致谢。

try one of this: 尝试以下方法之一:

a) create empty file plain.xml and permission to 0666 chmod 0666 plain.xml a)创建一个空文件plain.xml并获得对0666 chmod 0666 plain.xml

or 要么

b) set permission on parent Directory your php file. b)在父目录上设置您的php文件的权限。 chmod 0777 DirectoryWithMyFile

You can do this in FTP client or SSH. 您可以在FTP客户端或SSH中执行此操作。

Another Way - from phpinfo() find tmp dir and use this dir. 另一种方法-从phpinfo()找到tmp目录并使用此目录。

I resolved my problem for decryption by another way using php. 我通过使用php的另一种方式解决了解密问题。 If anybody looking for same follow this. 如果有人在寻找相同的东西,请遵循此步骤。

AES -192 encryption/decryption using php? AES -192使用PHP进行加密/解密?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM