encrypt-body-spring-boot-starter

Introduction: 🔒 SpringBoot 控制器统一的响应体编码/加密与请求体解密的注解处理方式,支持 MD5/SHA/AES/DES/RSA | SpringBoot controller unified response body encoding/encryption and request body decryption annotation processing method.
More: Author   ReportBugs   
Tags:

简体中文 | English

encrypt-body-spring-boot-starter是对springboot控制器统一的响应体编码/加密与请求体解密的注解处理方式,支持 MD5/SHA/AES/DES/RSA。

编码/加密解密支持

  • 可进行编码/加密的方式有:
      • [x] MD5
      • [x] SHA-1 / SHA-256
      • [x] AES
      • [x] DES
      • [x] RSA
  • 可进行解密的方式有:
      • [x] AES
      • [x] DES
      • [x] RSA

        引入注册

        导入依赖

        在项目的pom.xml中引入依赖:
        <dependency>
        <groupId>cn.licoy</groupId>
        <artifactId>encrypt-body-spring-boot-starter</artifactId>
        <version>1.2.3</version>
        </dependency>
        

        启用组件

  • 在工程对应的Application类中增加@EnableEncryptBody注解,如: ```java @EnableEncryptBody @SpringBootApplication public class Application {

    public static void main(String[] args) {

      SpringApplication.run(Application.class, args);
    

    }

}

### 配置参数
在项目的`application.yml`或`application.properties`文件中增加参数配置,例如:
```yaml
encrypt:  
    body:
      aes-key: 12345678 #AES 加密秘钥
      des-key: 12345678 #DES 加密秘钥
      # more...

使用

对整个控制器生效

@RestController
@EncryptBody
@RequestMapping("/test")
public class TestController {

    @GetMapping
    public String test(){
        return "hello world";
    }

}

对单一请求生效

@Controller
@RequestMapping("/test")
public class TestController {

    @GetMapping
    @ResponseBody
    @EncryptBody(value = EncryptBodyMethod.AES)
    public String test(){
        return "hello world";
    }

}

对响应的声明类生效

@Data
@EncryptBody
public class User implements Serializable {

    private String name;

    private String email;

    private Integer number;

    private String numberValue;

}

对声明类单一属性生效

@Data
@EncryptBody
@FieldBody
public class User implements Serializable {

    private String name;

    @FieldBody
    @AESEncryptBody(key = "1234567812345678")
    private String email;

    @FieldBody(field = "numberValue", clearValue = true)
    @DESEncryptBody(key = "1234567812345678")
    private Integer number;

    private String numberValue;

}

注解一览表

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools