rsa-encrypt-body-spring-boot
Spring Boot接口加密,可以对返回值、参数值通过注解的方式自动加解密。
[]()
Apache Maven
<dependency>
<groupId>cn.shuibo</groupId>
<artifactId>rsa-encrypt-body-spring-boot</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
Gradle Groovy DSL
implementation 'cn.shuibo:rsa-encrypt-body-spring-boot:1.0.1.RELEASE'
Gradle Kotlin DSL、Scala SBT、Apache Ivy、Groovy Grape、Leiningen、Apache Buildr、Maven Central Badge、PURL、Bazel方式请阅读Spring Boot接口RSA自动加解密
<dependency>
<groupId>cn.shuibo</groupId>
<artifactId>rsa-encrypt-body-spring-boot</artifactId>
<version>1.0.2.RELEASE</version>
</dependency>
@SpringBootApplication
@EnableSecurity
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
rsa:
encrypt:
open: true # 是否开启加密 true or false
showLog: true # 是否打印加解密log true or false
timestampCheck: true # 是否开启时间戳检查 ture 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();
}
@Decrypt
public @interface Decrypt{
/**
* 请求参数一定要是加密内容
*/
boolean required() default false;
/**
* 请求数据时间戳校验时间差
* 超过(当前时间-指定时间)的数据认定为伪造
* 注意应用程序需要捕获 {@link cn.shuibo.exception.EncryptRequestException} 异常
*/
long timeout() default 3000;
}
### 3.About author
![码农届首家互娱自媒体](https://images.gitee.com/uploads/images/2020/0529/112357_aac5a702_1674154.jpeg "kxmn.jpg")
- Blog:https://shuibo.cn
- QQ群:7277991 [点击加入](http://shang.qq.com/wpa/qunwpa?idkey=d919a3676fe81a081cf90698a55b38c162285c92ef3c7a529972f39cd7787ef9)