[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OpenSSl encrpt and decrypt a String



	Hi.

On Fri, Oct 16, 2020 at 03:58:46PM +0200, Philipp Ewald wrote:
> echo -n "That's the text" | openssl enc -aes-256-cbc -a -A -nosalt
> 
> gives me following "String":
> ttn39k7YiglePLvmmc6s+w==

Correct so far, assuming that you've entered a passphrase from the
keyboard.


> echo -n "ttn39k7YiglePLvmmc6s+w==" | openssl base64 -d | openssl enc -d -aes-256-cbc

Wrong one. By default openssl assumes that plaintext is salted before
the encryption.


> echo -n "ttn39k7YiglePLvmmc6s+w==" | openssl base64 -d | openssl enc -d -aes-256-cbc -nosalt

That one worked for me, but I've used a different passphrase, so the
ciphertext was different:

$ echo -n "That's the text" | openssl enc -aes-256-cbc -a -A -nosalt -k foo 2>/dev/null
3zGGAzM31Vsu9cax67TUrw==
$ echo -n 3zGGAzM31Vsu9cax67TUrw== | base64 -d | openssl enc  -d -aes-256-cbc -nosalt -k foo 2>/dev/null
That's the text
$ openssl version
OpenSSL 1.1.1d  10 Sep 2019

Reco


Reply to: