Coder Social home page Coder Social logo

vitorhenriquec / encrypt-body-spring-boot-starter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from licoy/encrypt-body-spring-boot-starter

0.0 0.0 0.0 321 KB

SpringBoot controller unified response body encoding/encryption and request body decryption annotation processing method.

License: Apache License 2.0

Java 100.00%

encrypt-body-spring-boot-starter's Introduction

简体中文 | English

介绍

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

编码/加密解密支持

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

引入注册

导入依赖

在项目的pom.xml中引入依赖:

<dependency>
    <groupId>cn.licoy</groupId>
    <artifactId>encrypt-body-spring-boot-starter</artifactId>
    <version>1.2.3</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加密秘钥
      # 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;

}

注解一览表

开源协议

Apache 2.0

encrypt-body-spring-boot-starter's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.