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 (710,328
Spring Boot (12,323
Spring (4,989
Spring Mvc (1,869
Spring Security (1,539
Aes (701
Rsa (612
Md5 (390
Encrypt (290
Sha1 (260
Decrypt (174
Related Projects