先吐槽一下那些无脑转载的“砖家、叫兽”,误人子弟。
一句话:运行时需要加上参数jasypt.encryptor.password=saltnewfor
详细步骤如下:
1、添加Maven依赖(Gradle的类似,不举例了)
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
2、生成加密密码
第一步:下载jar包:jasypt-1.9.2.jar
第二步:执行加密:
java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="zhilin123!@#" password=saltnewfor algorithm=PBEWithMD5AndDES
其中password=saltnewfor,saltnewfor 代表的是盐、盐、盐 ,记住他,后续你需要它。
input="zhilin123!@#" ,这个才是你的数据库明文密码(当然,如果你想给别的数据加密也可以)
执行完命令会输出以下信息: