Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a message, I know the password and the cipher that was used to encrypt it, but I can't figure out how to ask openssl to decrypt it.

I see the cipher in the output from the ciphers command, and the man page lists a enc command for Encoding with Ciphers, but I can't find how I would do the opposite, decode a message.

share|improve this question
What program is used to encrypt the file? It is very likely that the encryption program adds metadata to the encrypted content, like the initialization vector, salt, version of the program etc. If you treat the whole as encrypted bits, you will get garbage out. – Siyuan Ren Oct 15 '14 at 2:05

I think you're looking for something like this:

openssl yourcipher -d < yourfile

For example if the file was encrypted using des3 cipher, and the file is /path/to/file.des3 then:

openssl des3 -d < /path/to/file.des3

It will ask you for the passphrase.

If the file is base64 encoded, then you should be able decode and decrypt like this:

openssl enc -base64 -d < /path/to/file | openssl yourcipher -d
share|improve this answer
Trying that, after entering the passphrase, I get "bad magic number". Not sure how to interpret that. – user50849 Jan 15 '14 at 22:27
That error is common when the file is not really an encrypted file... Perhaps you need to unzip it first? – janos Jan 15 '14 at 22:32
If I've understood my instructions correctly, my file is base64 encoded (It looks like base64 as well, though that's no guarantee of course). But I've tried passing it through base64 -d [input] > [output] and then openssl [cipher] -d < [output] as well as deciphering the file as is, and I get the same "bad magic number" in both cases. – user50849 Jan 15 '14 at 22:53
@user50849 I updated my answer thought it looks like you're already doing that... After you decode from base64, what does the file command tell you? Is the file binary? – janos Jan 15 '14 at 23:04
I tried your added base64 command, and unfortunately I get the same error. file says data about the decoded file. I assume that your answer is correct and that something is wrong on my end. Possibly I've corrupted the input or similar. I'll try to work that out and get back. – user50849 Jan 15 '14 at 23:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.