jasypt-spring-boot

jasypt-spring-boot 配置文件加密

maven 引入

<dependency>
  <groupId>com.github.ulisesbocchiogroupId>
  <artifactId>jasypt-spring-boot-starterartifactId>
  <version>1.14version>
dependency>

生产加密密文

C:\.m2\repository\org\jasypt\jasypt\1.9.2>
java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password=@^_^123aBcZ* algorithm=PBEWithMD5AndDES

input:密码
password 加密密匙
algorithm 加密算法

输出:


----ENVIRONMENT-----------------

Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.171-b11



----ARGUMENTS-------------------

algorithm: PBEWithMD5AndDES
input: 123456
password: @_123aBcZ*



----OUTPUT----------------------

V+5WL0DmH5Wwt0Ne8hzMVQ==

spring配置文件配置
jasypt.encryptor.password=@_123aBcZ*
spring.datasource.password =ENC(V+5WL0DmH5Wwt0Ne8hzMVQ==)

或者启动参数

java -Dfile.encoding=UTF8 -Djasypt.encryptor.password=@_123aBcZ* -jar -Xmx512m settlement.jar

在docker容器中密文的密码可以设置成环境变量
java -Dfile.encoding=UTF8 -Djasypt.encryptor.password=${JASYPT_PASSWORD} -jar -Xmx512m settlement.jar

你可能感兴趣的:(程序员,java,spring,boot)