openssl

OpenSSL "error reading input file" and "bad magic number"


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

Solution

  • 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.