br.
br.

Reputation: 1299

OpenSSL one line base64 input. error reading input file

I have AES-encrypted file, which encoded to base64 one-line string (without breaklines) and need to decrypt it. Here it is.

But when i use:

openssl enc -d -a -aes-256-cbc -in encrypted -out decrypted

OpenSSL throws "error reading input file"
But base64 util decrypts it like a charm:

base64 -d encrypted | openssl enc -d -aes-256-cbc > decrypted

Trying to find find the cause and convert to one-line base64 file:

base64 -w 0 aesfile | openssl enc -d -a -aes-256-cbc > decrypted
# error reading input file

base64 aesfile | openssl enc -d -a -aes-256-cbc > decrypted
# no errors, file decrypted

Conclusion: OpenSSL can't decode non-multiline base64 inputs

Upvotes: 14

Views: 32264

Answers (2)

user18785436
user18785436

Reputation: 1

If the encryption format is different than the decryption format used in the script, it throws similar error.

Make sure you use the same decryption format used for the file during encryption.

Upvotes: 0

Geograph
Geograph

Reputation: 2596

Encrypt

openssl enc -aes-256-cbc -pass pass:YOURPASSWORD -p -in msg.txt -out enc.txt -base64

Decrypt

openssl enc -aes-256-cbc -base64 -pass pass:YOURPASSWORD -d -p -in enc.txt -out dec.txt

If there's no newline in the encrypted file after the base64 line, you get an error saying error reading input file.

Upvotes: 19

Related Questions