openssl aes-256 encrypted file on windows cant be decrypted on linux

后端 未结 1 612
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 07:51

I have a php document repository application running on windows apache, this application will aes-encrypt any uploaded document with the following command:

e         


        
相关标签:
1条回答
  • 2021-01-14 08:11

    I found the solution :-), the problem is the windows echo command adds three characters to the end of password, that are space,CR and LF characters, and the linux echo command seems to not feed those characters and so the openssl command is not receiving the same password used to encrypt.

    The solution was to add those three characters to the password in Linux, that is possible because the echo command has escape sequences to insert hexadecimal values.So, following my example, the correct decrypt command that is now working for me in linux is:

    echo $'MyPass34\x20\x0d\x0a' | /usr/bin/openssl aes-256-cbc -pass stdin -d -in somefile.pdf -out decriptedfile.pdf
    

    Hope this can help someone!

    0 讨论(0)
提交回复
热议问题