springboot使用jasypt对的datasource密码加密
- - 开源软件 - ITeye博客2.配置加密参数(可以理解为加密的salt). password: BdaObXaELAA #(或者用123456). cmd运行下面的,将其中jar的位置改变,好友password是项目配置中配置的jasypt.encryptor.password=BdaObXaELAA,input是原始的密码.
<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>1.17</version> </dependency>
jasypt: encryptor: password: BdaObXaELAA #(或者用123456)
datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/saas_official_document?useUnicode=true&characterEncoding=utf8 username: appuser password: ENC(BfsoZM9dAAU4lVp+pE47Y/0N9fqcci1A)
cmd运行下面的,将其中jar的位置改变,好友password是项目配置中配置的jasypt.encryptor.password=BdaObXaELAA,input是原始的密码
java -cp C:\Users\Administrator\.m2\repository\org\jasypt\jasypt\1.9.2\jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password=BdaObXaELAA algorithm=PBEWithMD5AndDES
➜ ~ java -cp /Users/root/.m2/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123455" password=123456 algorithm=PBEWithMD5AndDES ----ENVIRONMENT----------------- Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.162-b12 ----ARGUMENTS------------------- algorithm: PBEWithMD5AndDES input: 123455 password: 123456 ----OUTPUT---------------------- ZeHyjAyYMsay6LFwkkwssQ==