Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 295
br. Avatar asked Feb 13 '14 22:02

br.


1 Answers

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.

like image 65
Geograph Avatar answered Nov 16 '22 00:11

Geograph