当前位置:   article > 正文

SpringBoot 使用Jasypt_jasypt-spring-boot使用

jasypt-spring-boot使用

1、导入依赖(自动配置)

<dependency>
   <groupId>com.github.ulisesbocchio</groupId>
   <artifactId>jasypt-spring-boot-starter</artifactId>
   <version>2.1.1</version>
</dependency>

2、配置文件

jasypt:
  encryptor:
    password: *********  #加密秘钥

注意:每次生成的密码都不一样

需要加密的信息:

spring.datasource.password=ENC(************)

生成加密信息:

  1. @Test
  2. void textEncrpyt(){
  3. BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
  4. // 加密秘钥
  5. textEncryptor.setPassword("***********");
  6. String newString = textEncryptor.encrypt("root");
  7. System.out.println(newString);
  8. System.out.println(textEncryptor.decrypt(newString));
  9. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/945679?site
推荐阅读
相关标签
  

闽ICP备14008679号