From 6f453d9b72738b7bc0e211ce4e664a53ca458770 Mon Sep 17 00:00:00 2001 From: Licoy Date: Tue, 17 May 2022 18:06:25 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=8F=91=E5=B8=831.2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 75 ++++++++++++++++++++++++------- README_EN.md | 125 +++++++++++++++++++++++++++++++++------------------ pom.xml | 5 ++- 3 files changed, 143 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index d0e3b5e..7e6b12a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ 简体中文 | [English](./README_EN.md) ## 介绍 -`encrypt-body-spring-boot-starter`是对SpringBoot控制器统一的响应体加密与请求体解密的注解处理方式,支持MD5/SHA/AES/DES/RSA。 +`encrypt-body-spring-boot-starter`是对`springboot`控制器统一的响应体编码/加密与请求体解密的注解处理方式,支持MD5/SHA/AES/DES/RSA。 [![](https://img.shields.io/github/release/Licoy/encrypt-body-spring-boot-starter.svg)]() [![](https://img.shields.io/github/issues/Licoy/encrypt-body-spring-boot-starter.svg)]() [![](https://img.shields.io/github/issues-pr/Licoy/encrypt-body-spring-boot-starter.svg)]() [![](https://img.shields.io/badge/author-Licoy-ff69b4.svg)]() -## 加密解密支持 -- 可进行加密的方式有: +## 编码/加密解密支持 +- 可进行编码/加密的方式有: - - [x] MD5 - - [x] SHA-1 / SHA-256 - - [x] AES @@ -17,16 +17,18 @@ - - [x] AES - - [x] DES - - [x] RSA -## 使用方法 -- 在`pom.xml`中引入依赖: +## 引入注册 +### 导入依赖 +在项目的`pom.xml`中引入依赖: ```xml cn.licoy encrypt-body-spring-boot-starter - 1.1.0 + 1.2.0 ``` -- 在工程对应的`Application`类中增加@EnableEncryptBody注解,例如: +### 启用组件 +- 在工程对应的`Application`类中增加`@EnableEncryptBody`注解,如: ```java @EnableEncryptBody @SpringBootApplication @@ -38,45 +40,84 @@ public class Application { } ``` -- 参数配置 -在项目的`application.yml`或`application.properties`文件中进行参数配置,例如: +### 配置参数 +在项目的`application.yml`或`application.properties`文件中增加参数配置,例如: ```yaml encrypt: body: aes-key: 12345678 #AES加密秘钥 des-key: 12345678 #DES加密秘钥 + # more... ``` -- 对控制器响应体进行加密 +## 使用 +### 对整个控制器生效 ```java -@Controller +@RestController +@EncryptBody @RequestMapping("/test") public class TestController { @GetMapping - @ResponseBody - @EncryptBody(value = EncryptBodyMethod.AES) public String test(){ return "hello world"; } } ``` -或者使用`@RestController`对整个控制器的方法响应体都进行加密: +### 对单一请求生效 ```java -@RestController -@EncryptBody +@Controller @RequestMapping("/test") public class TestController { @GetMapping + @ResponseBody + @EncryptBody(value = EncryptBodyMethod.AES) public String test(){ return "hello world"; } +} +``` +### 对响应的声明类生效 +```java +@Data +@EncryptBody +public class User implements Serializable { + + private String name; + + private String email; + + private Integer number; + + private String numberValue; + +} +``` +### 对声明类单一属性生效 +```java +@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; + } ``` ## 注解一览表 -- [加密注解一览表](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/加密注解一览表) +- [编码/加密注解一览表](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/加密注解一览表) - [解密注解一览表](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/解密注解一览表) ## 开源协议 [Apache 2.0](/LICENSE) diff --git a/README_EN.md b/README_EN.md index 9c139e0..484318b 100644 --- a/README_EN.md +++ b/README_EN.md @@ -1,34 +1,35 @@ [简体中文](./README.md) | English -> This English document is translated by Google Translate. If you are willing to assist us with the documentation, please submit the relevant Pull Request. -## Introduction -`encrypt-body-spring-boot-starter` it is a unified processing method for response body encryption and request body decryption of SpringBoot controller, and supports MD5/SHA/AES/DES/RSA. - - [![](https://img.shields.io/github/release/Licoy/encrypt-body-spring-boot-starter.svg)]() - [![](https://img.shields.io/github/issues/Licoy/encrypt-body-spring-boot-starter.svg)]() - [![](https://img.shields.io/github/issues-pr/Licoy/encrypt-body-spring-boot-starter.svg)]() - [![](https://img.shields.io/badge/author-Licoy-ff69b4.svg)]() -## Encryption and decryption support -- There are ways to encrypt: +## Introduce +`encrypt-body-spring-boot-starter` is a unified annotation processing method for response body encoding/encryption and request body decryption for `springboot` controller, and supports MD5/SHA/AES/DES/RSA. + +[![](https://img.shields.io/github/release/Licoy/encrypt-body-spring-boot-starter.svg)]() +[![](https://img.shields.io/github/issues/Licoy/encrypt-body-spring-boot-starter.svg)]() +[![](https://img.shields.io/github/issues-pr/Licoy/encrypt-body-spring-boot-starter.svg)]() +[![](https://img.shields.io/badge/author-Licoy-ff69b4.svg)]() +## Support +- The ways in which encoding/encryption can be performed are: - - [x] MD5 - - - [x] SHA-1 / SHA-256 + - - [x] SHA-1/SHA-256 - - [x] AES - - [x] DES - - [x] RSA -- There are ways to decrypt: +- The methods that can be decrypted are: - - [x] AES - - [x] DES - - [x] RSA -## Usage method -- Introducing dependencies in `pom.xml`: -```xml +## Import registration +### Import dependencies +Introduce dependencies in the project's `pom.xml`: +````xml cn.licoy encrypt-body-spring-boot-starter - 1.1.0 + 1.2.0 -``` -- Add the @EnableEncryptBody annotation to the `Application` class corresponding to the project, for example: -```java +```` +### Enable component +- Add the `@EnableEncryptBody` annotation to the `Application` class corresponding to the project, such as: +````java @EnableEncryptBody @SpringBootApplication public class Application { @@ -38,49 +39,85 @@ public class Application { } } -``` -- Parameter configuration -Configure the parameters in the project's `application.yml` or `application.properties` file, for example: -```yaml -encrypt: +```` +### Configuration parameters +Add parameter configuration in the `application.yml` or `application.properties` file of the project, for example: +````yaml +encrypt: body: aes-key: 12345678 #AES encryption key des-key: 12345678 #DES encryption key -``` -- Encrypt the controller response body -```java -@Controller + # more... +```` +## Use +### Valid for the entire controller +````java +@RestController +@EncryptBody @RequestMapping("/test") public class TestController { @GetMapping - @ResponseBody - @EncryptBody(value = EncryptBodyMethod.AES) public String test(){ return "hello world"; } } -``` -Or use `@RestController` to encrypt the method response body of the entire controller: -```java -@RestController -@EncryptBody +```` +### Valid for a single request +````java +@Controller @RequestMapping("/test") public class TestController { @GetMapping + @ResponseBody + @EncryptBody(value = EncryptBodyMethod.AES) public String test(){ return "hello world"; } } -``` -## Annotated list -- [Encrypted annotation list](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/加密注解一览表) -- [Decryption annotation list](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/解密注解一览表) -## Discuss - -- Author blog:[https://www.licoy.cn](https://www.licoy.cn) -## Open source agreement -[Apache 2.0](/LICENSE) +```` +### Effective on the declared class of the response +````java +@Data +@EncryptBody +public class User implements Serializable { + + private String name; + + private String email; + + private Integer number; + + private String numberValue; + +} +```` +### Effective for a single attribute of the declared class +````java +@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; + +} +```` +## Annotation list +- [Encryption/Encryption Annotation List](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/加密注解一览表) +- [Decryption Annotation List](https://github.com/Licoy/encrypt-body-spring-boot-starter/wiki/解密注解一览表) +## License +[Apache 2.0](/LICENSE) \ No newline at end of file diff --git a/pom.xml b/pom.xml index e463fcc..858f34f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.licoy encrypt-body-spring-boot-starter - 1.1.0 + 1.2.0 encrypt-body-spring-boot-starter encrypt-body-spring-boot-starter是SpringBoot控制器统一的响应体加密与请求体解密的注解处理方式,支持MD5/SHA/AES/DES/RSA @@ -109,6 +109,9 @@ ${java.version} ${java.version} true + + **/test/** +