I have an encrypted file that is encoded with base64:
U2FsdGVkX19hoS7DQSHERIkTzT3Hp7RUEjMAh6UDOP6YjRB/XQey7TKoySJiZTni
WbCfJLhihMD9CkohBnvrY8UBkh2dbi1K6hQqf8X9ENGFNWUxqmhYMG+WrBsPwhpB
I1qUt91IKlPS1YMZ0UDyBieDwFyqFi3izGhqXoOuzo8=
and when I run:
cat encryptedfile | openssl enc -d -a
I get a bunch of question mark symbols. Why does that happen?
Let's see what
file
has to say about your data:So, after base64-decoding, you get the encrypted data. And now with
od -c
:Clearly not all of those bytes are text in our usual encodings (ASCII or UTF-8). The terminal has no way to make sense of most of those bytes, and shows them as question marks. Some of those show up as ASCII text, some as symbols higher up in the Unicode chart (
Ώ
, for example), because the terminal tries to make some sense of the data.Encrypted data is not expected to be text, so there's no reason for it to stick byte sequences permitted by some encoding. It can use any sequence of bytes available, and it does.
A base64 encoded string consists only of 64 printable characters,
e.g. for MIME base64
A-Z
,a-z
,0-9
,+
,/
.If you decode the string you will get the full byte range from 0..255 which also contains non-printable characters like control characters which show up as question marks.