OpenSSL “error reading input file” and “bad magic number”

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I'm trying to encrypt a simple string "Hello world." with the OpenSSL command line tool. I've tried both encrypting using both base64 and binary. But I'm getting some unhelpful errors.

$ "Hello world." > plain.txt $ openssl enc -aes-128-ecb -e -base64 -in plain.txt > enc.txt enter aes-128-ecb encryption password: Verifying - enter aes-128-ecb encryption password: $ cat enc.txt U2FsdGVkX18ZoAY34fL2aMO0Bu5AJnewemhfiBmSL1IJujqOtpJm7V0C+Tt83egJ $ openssl enc -aes-128-ecb -d -base64 -in enc.txt > out.txt enter aes-128-ecb decryption password: error reading input file 

Then I try binary

$ "Hello world." > plain.txt $ openssl enc -aes-128-ecb -e -in plain.txt > enc.bin enter aes-128-ecb encryption password: Verifying - enter aes-128-ecb encryption password: $ openssl enc -aes-128-ecb -d -in enc.bin > out.txt  enter aes-128-ecb decryption password: bad magic number 

回答1:

Mark, I don't see anything wrong with your commands. They all worked fine on my system. So the problem must be somewhere else.

I'd recommend trying a different installation/version of OpenSSL, or a different system.



回答2:

I think maybe your commands are not wrong, because I met the same problem these days. The TXT file could not change into the second line automatically, thus, you need to input an "Enter" at the end of the cipher text and save the text. Then, you can input your command again.

$ openssl enc -des -d -base64 -in atxt > a2.txt

enter des-cbc decryption password:

enter image description here



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!