spring-boot-request-body-encrypt

使用AES对称加密算法对spring mvc的请求参数及返回结果进行加密解密

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

com.ofwiki
ArtifactId

ArtifactId

spring-boot-request-body-encrypt
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

spring-boot-request-body-encrypt
使用AES对称加密算法对spring mvc的请求参数及返回结果进行加密解密
Project URL

Project URL

https://github.com/huangjiesen/spring-boot-request-body-encrypt
Source Code Management

Source Code Management

https://github.com/huangjiesen/spring-boot-request-body-encrypt

Download spring-boot-request-body-encrypt

How to add to project

<!-- https://jarcasting.com/artifacts/com.ofwiki/spring-boot-request-body-encrypt/ -->
<dependency>
    <groupId>com.ofwiki</groupId>
    <artifactId>spring-boot-request-body-encrypt</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.ofwiki/spring-boot-request-body-encrypt/
implementation 'com.ofwiki:spring-boot-request-body-encrypt:1.0.0'
// https://jarcasting.com/artifacts/com.ofwiki/spring-boot-request-body-encrypt/
implementation ("com.ofwiki:spring-boot-request-body-encrypt:1.0.0")
'com.ofwiki:spring-boot-request-body-encrypt:jar:1.0.0'
<dependency org="com.ofwiki" name="spring-boot-request-body-encrypt" rev="1.0.0">
  <artifact name="spring-boot-request-body-encrypt" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.ofwiki', module='spring-boot-request-body-encrypt', version='1.0.0')
)
libraryDependencies += "com.ofwiki" % "spring-boot-request-body-encrypt" % "1.0.0"
[com.ofwiki/spring-boot-request-body-encrypt "1.0.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar 2.1.7.RELEASE
org.springframework.boot : spring-boot-autoconfigure jar 2.1.7.RELEASE
org.springframework.boot : spring-boot-configuration-processor Optional jar 2.1.7.RELEASE
commons-codec : commons-codec jar 1.11
commons-io : commons-io jar 2.6
com.fasterxml.jackson.core : jackson-annotations jar 2.8.8
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.8.8

Project Modules

There are no modules declared in this project.

项目介绍

使用AES对称加密算法,对以下类型的请求参数及返回结果数据进行加解密

  1. 对@RequestBody或HttpEntity方法参数进行解密
  2. 对@ResponseBody或ResponseEntity类型的返回数据进行加密

使用说明

  1. 添加依赖
    <dependency>
        <groupId>com.ofwiki</groupId>
        <artifactId>spring-boot-request-body-encrypt</artifactId>
        <version>1.0.0</version>
    </dependency>
  2. 配置application.yml
    spring:
      encrypt:
        aes-key: 0123456789123456  # AES密钥,可选长度为128位(16字节)、192位(24字节)、256位(32字节),长度大于128位需要下载JCE无限制权限策略文件
        aes-iv: 1234560123456789   # AES的初始化向量,长度为128位(16字节) 
        debug: false               # 开启调试模式,调试模式下不进行加解密操作
  3. 代码示例
    @RestController
    @RequestMapping("order")
    public class OrderController {
        @PostMapping("get_detail")
        // @Encrypt     // 对返回数据进行加密
        // @Decrypt     // 对请示参数进行解密
        @EncryptDecrypt // 等效于同时使用@Encrypt,@Decrypt两个注解
        public Result<OrderDTO> get(@RequestBody OrderReq req) {
            return Result.success(orderService.getDetail(req.getId()));
        }
    }

Versions

Version
1.0.0