66 Star 389 Fork 105

Bobby / rsa-encrypt-body-spring-boot

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

1.介绍

rsa-encrypt-body-spring-boot
Spring Boot接口加密,可以对返回值、参数值通过注解的方式自动加解密 。

2.使用方法

Apache Maven

<dependency>
  <groupId>cn.shuibo</groupId>
  <artifactId>rsa-encrypt-body-spring-boot</artifactId>
  <version>1.0.1.RELEASE</version>
</dependency>

Gradle Groovy DSL

implementation 'cn.shuibo:rsa-encrypt-body-spring-boot:1.0.1.RELEASE'

Gradle Kotlin DSLScala SBTApache IvyGroovy GrapeLeiningenApache BuildrMaven Central BadgePURLBazel方式请阅读Spring Boot接口RSA自动加解密

  • 以Maven为例,在pom.xml中引入依赖
<dependency>
    <groupId>cn.shuibo</groupId>
    <artifactId>rsa-encrypt-body-spring-boot</artifactId>
    <version>1.0.1.RELEASE</version>
</dependency>
  • 启动类Application中添加@EnableSecurity注解
@SpringBootApplication
@EnableSecurity
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
  • 在application.yml或者application.properties中添加RSA公钥及私钥
rsa:
  encrypt:
    open: true # 是否开启加密 true  or  false
    showLog: true # 是否打印加解密log true  or  false
    publicKey: # RSA公钥
    privateKey: # RSA私钥
  • 对返回值进行加密
@Encrypt
@GetMapping("/encryption")
public TestBean encryption(){
    TestBean testBean = new TestBean();
    testBean.setName("shuibo.cn");
    testBean.setAge(18);
    return testBean;
}
  • 对传过来的加密参数解密
@Decrypt
@PostMapping("/decryption")
public String Decryption(@RequestBody TestBean testBean){
    return testBean.toString();
}

3.About author

码农界首家互娱自媒体「开心码农」

码农届首家互娱自媒体

「开心码农」和成千上百万个程序猿一起996!

Comments ( 33 )

Sign in for post a comment

About

Spring Boot 接口请求参数自动加解密 spread retract
Java
Apache-2.0
Cancel

Releases

No release

Gitee Metrics

Contributors

All

Activities

load more
can not load any more
Java
1
https://gitee.com/ishuibo/rsa-encrypt-body-spring-boot.git
git@gitee.com:ishuibo/rsa-encrypt-body-spring-boot.git
ishuibo
rsa-encrypt-body-spring-boot
rsa-encrypt-body-spring-boot
master

Search

103611 48b8ff67 1899542 103622 4d02230c 1899542