1 Star 0 Fork 133

grindelwald / encrypt-body-spring-boot-starter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
Licoy 提交于 2020-12-14 11:17 . Update README.md

简体中文 | English

介绍

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

加密解密支持

  • 可进行加密的方式有:
      • MD5
      • SHA-224 / 256 / 384 / 512
      • AES
      • DES
      • RSA
  • 可进行解密的方式有:
      • AES
      • 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

Java
1
https://gitee.com/fizzyelf24601/encrypt-body-spring-boot-starter.git
git@gitee.com:fizzyelf24601/encrypt-body-spring-boot-starter.git
fizzyelf24601
encrypt-body-spring-boot-starter
encrypt-body-spring-boot-starter
master

搜索帮助