I want to decrypt AES encrypted data with openssl command.
GD5YV2naJZ/x3mQnfictWQ==
(base64 encoded)uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g
LNP8U7pc6GjxzxAtgw4s3A==
(base64 encoded)Follow these steps:
$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl base64 -d > data.enc
$ iv=$( echo LNP8U7pc6GjxzxAtgw4s3A== | openssl base64 -d | xxd -p | tr -d '\n' )
$ echo $iv
2cd3fc53ba5ce868f1cf102d830e2cdc
$ key=$( echo uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g | xxd -p | tr -d '\n' )
$ echo $key
754865324d436d67674c6c7567704742694d56755854636b374f54384e6b38670a
$ openssl aes-256-cbc -d -in data.enc -K $key -iv $iv
s:4:"Test";
With -base64
option, the decrypt command can directly use base64 encoded data as the input:
$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl aes-256-cbc -d -base64 -K $key -iv $iv
s:4:"Test";