Jasypt Encrypt/Decrypt in command line
It’s needed to encrypt passwords of PROD or even NON-PROD when they’re in configuration files. Jasypt is used as a tools to encrypt/decrypt password in our application. And it can be done from command line. Here we go
Encrypt
java -cp ~/.m2/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="input-to-encrypt" password="XXXXXX" algorithm=PBEWithMD5AndDES
Then you’ll see
----OUTPUT----------------------
m3CGfER1ZH32bLGgflT0McyLQkRkwiabwxocleSzBCY=
Decrypt
java -cp ~/.m2/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI input="m3CGfER1ZH32bLGgflT0McyLQkRkwiabwxocleSzBCY=" password="XXXXXX" algorithm=PBEWithMD5AndDES
Then, you got the password back
----OUTPUT----------------------
input-to-encrypt