首页 > 其他分享 >Springboot项目密码加密器jasypt

Springboot项目密码加密器jasypt

时间:2023-03-20 18:33:05浏览次数:29  
标签:StandardPBEStringEncryptor Springboot spring encryptor boot jasypt 加密器 password

最新版依赖

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

原理

当读取到如下所示带ENC()包裹的内容,会调用jasypt进行解密后再使用。

password= ENC(密文)

生成密码样例类:

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.iv.RandomIvGenerator;

public class JasyptGenerator {
    public static void main(String[] args) {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        encryptor.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");
        encryptor.setPassword("abcdefg");
        encryptor.setIvGenerator(new RandomIvGenerator());

        // 加密
        String encryptText = encryptor.encrypt("7ujm8ik,8ikjjjkl;l");
        System.out.println("7ujm8ik,8ikjjjkl;l,加密后的信息:" + encryptText);
	}
}

spring-boot使用

  1. 运行spring-boot项目idea加上程序参数:
    --jasypt.encryptor.password=abcdefg
  2. 运行jar程序时加上
    -Djasypt.encryptor.password=abcdefg

标签:StandardPBEStringEncryptor,Springboot,spring,encryptor,boot,jasypt,加密器,password
From: https://www.cnblogs.com/bigjor/p/17237278.html

相关文章

  • SpringBoot
    一、SpringBoot的入门SpringBoot是由Pivotal团队提供的全新框架,其设计目的是用来简化Spring应用的初始搭建以及开发过程spring优化SpringBoot配置繁琐==>自......
  • SpringBoot 2.6.0 以上 @Autowired 没有解决循环依赖
    使用@Autowired,仍在提示循环依赖,提示:Asalastresort,itmaybepossibletobreakthecycleautomaticallybysettingspring.main.allow-circular-referencesto......
  • MongoDB简介及SpringBoot整合
    一、概述MongoDB中的记录是一个文档,它是一个数据结构组成字段和值对。MongoDB文档类似于JSON。对象。字段的值可能包括其他文档、数组、和文档数组:数据库(Database):和关系型......
  • 你能说出SpringBoot自动装配的原理吗
    SpringBoot目的是用来简化Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。在过去,我们要让一个Spring项......
  • SpringBoot+Vue+EasyExcel实现excel简单导入导出
    1.先导入EasyExcel依赖<dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>3.1.......
  • day07-SpringBoot接收参数相关注解
    SpringBoot接收参数相关注解1.基本介绍SpringBoot接收客户端提交数据/参数会使用到相关注解详解@PathVariable、@RequestHeader、@ModelAttribute、@RequestParam、@Co......
  • SpringBoot集成Swagger错误总结
    错误展示rorstartingApplicationContext.Todisplaytheconditionsreportre-runyourapplicationwith'debug'enabled.2023-03-1915:37:55.307ERROR12980---......
  • 第五天(SpringBoot基础第二篇)
    一、关于starterstater参赛人、发令员SpringBoot中的starter只是把我们某一模块,比如web开发时所需要的所有JAR包打包好给我们而已。不过它的厉害之处在于,能自动把......
  • 第四天(springBoot基础第一篇)
    springBoot基础1.什么是springBoot(概念及其特点)1.概念(1)介绍官网地址: https://spring.io/SpringBoot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应......
  • SpringBoot 统一页面异常处理
    相关博客:<arel="nofollow"href="https://hcshow.blog.csdn.net/article/details/103081763">SpringBoot统一异常处理</a>第一步:创建项目添加Maven依赖:<dependency>......