Linux – Openssl decrypt from encrypted text from command issue

cryptographyencryptionlinuxopenssl

I am using following command to decrypt an base64 string.

openssl enc -in ciphertext -out binarytext -d -a

openssl rsautl -decrypt -in binarytext -out plaintext -inkey private.pem

I am facing an issue when my cypher text has character / linux consider it as directory separator. How to fix this issue?

A sample cipher text as:

MpTF1+cqa23PdxQ6EoG9E77jfRJGYjORc4omawTg/g8jtUDZNNEeEr3waadTSLjQAfmJO94fpaA145yanoU9khrzCd/nAGIIAVwMC67UnsX+XY6dOEZMo41Z0dU1n42rUtkdXgldHXR1SQXaeDyjRnMj/mMMreNdykl8b4vNVPk=

The error which am getting as

ptpll081:Key admin$ openssl rsautl -decrypt -in
MpTF1+cqa23PdxQ6EoG9E77jfRJGYjORc4omawTg/g8jtUDZNNEeEr3waadTSLjQAfmJO94fpaA145yanoU9khrzCd/nAGIIAVwMC67UnsX+XY6dOEZMo41Z0dU1n42rUtkdXgldHXR1SQXaeDyjRnMj/mMMreNdykl8b4vNVPk=
-out plaintext -inkey PrivateKey.pem Error Reading Input File 22313:error:02001002:System library:fopen:No such file or
directory:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/bio/bss_file.c:126:fopen('MpTF1+cqa23PdxQ6EoG9E77jfRJGYjORc4omawTg/g8jtUDZNNEeEr3waadTSLjQAfmJO94fpaA145yanoU9khrzCd/nAGIIAVwMC67UnsX+XY6dOEZMo41Z0dU1n42rUtkdXgldHXR1SQXaeDyjRnMj/mMMreNdykl8b4vNVPk=','rb')
22313:error:2006D080:BIO routines:BIO_new_file:no such
file:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/bio/bss_file.c:129:

Best Answer

Try something like this:

openssl rsautl -decrypt -in binarytext -out myfile.txt -inkey private.pem

The important bit here is -out myfile.txt

Related Question