Hello
I want to suppress error message to the console when the password provided is wrong. Show content only when password is correct.
For ex, (password is 12345)
Code:
$ msg=$(echo "Hello World!" | openssl enc -aes-265-cdc -salt -a)
$ echo $msg
U2FsdGVkX19Gzenp7OyMIXOtvpAmetZrfPL4L8NAWd4=
# Correct password: 12345
$ echo $msg | openssl enc -aes-256-cbc -d -a
enter aes-256-cbc decryption password:
Hello World!
# Wrong password
$ echo $msg | openssl enc -aes-256-cbc -d -a
enter aes-256-cbc decryption password:
bad decrypt
140029904913984:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:../crypto/evp/evp_enc.c:536:
As you can see, if I input the wrong password there will be an error message (in bold). I want to suppress this error message. I'll base my next logic based on the exit status of that command but not on error message.
How to do that? I tried 2>/dev/null, but it doesn't work
Thanks