Awesome Open Source
Awesome Open Source

简体中文 | English

介绍

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

加密解密支持

  • 可进行加密的方式有:
      • [x] MD5
      • [x] SHA-224 / 256 / 384 / 512
      • [x] AES
      • [x] DES
      • [ ] RSA
  • 可进行解密的方式有:
      • [x] AES
      • [x] DES
      • [ ] RSA

使用方法

  • pom.xml中引入依赖:
<dependency>
    <groupId>cn.licoy</groupId>
    <artifactId>encrypt-body-spring-boot-starter</artifactId>
    <version>1.0.4.RELEASE</version>
</dependency>
  • 在工程对应的Application类中增加@EnableEncryptBody注解,例如:
@EnableEncryptBody
@SpringBootApplication
public class Application {
    
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
  • 参数配置 在项目的application.ymlapplication.properties文件中进行参数配置,例如:
encrypt:  
    body:
      aes-key: 12345678 #AES加密秘钥
      des-key: 12345678 #DES加密秘钥
  • 对控制器响应体进行加密
@Controller
@RequestMapping("/test")
public class TestController {

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

}

或者使用@RestController对整个控制器的方法响应体都进行加密:

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

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

}

注解一览表

开源协议

Apache 2.0


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
java (31,121
spring (514
springboot (277
spring-security (135
spring-mvc (120
aes (69
rsa (51
md5 (40
sha1 (32
encrypt (29
decrypt (22