Encryption一个基于SpringBoot2的数据传输加密框架

这是一个适用于SpringBoot2.x的HTTP数据加密框架,旨在增强项目中敏感数据的安全性,防止传输过程中的数据窃取。框架内置8种加密算法,支持注解驱动的解密参数,兼容Spring的验证和JSON处理,并提供调试模式和自定义加密器功能,还具备快速模拟请求数据的Mock功能。
摘要由CSDN通过智能技术生成

encryption

介绍

这是一个基于SpringBoot2.x的HTTP数据传输加密框架,该框架是为了给仍在使用HTTP进行数据传输的项目提供一层有效的数据安全防护,有效了避免重要敏感数据在传输过程中被窃取的风险,框架开箱即用,只需简单的配置就可以融入你的项目之中。

特性
  • 内置超过8种常用的算法或模式(对称、非对称、混合模式),基本上可以覆盖大部分项目的加密需求
  • 支持如@DecryptParam、@DecryptBody等在内的丰富的注解
  • 兼容Spring的Validation校验体系,可以无缝使用了其进行参数校验
  • 兼容SpringBoot2.x的JSON体系,对支持Jackson、Gson直接集成,
    提供了Fastjson的直接集成类,也可拓展其他Json框架的集成,做到整个项目的Json风格的统一
  • 内置调试模式,可方便查看和调试加解密时的数据,可配置详细输出类目
  • 支持自定义参数加密器
  • 新增Mock功能,支持快速模拟请求数据进行测试
项目开源地址

https://gitee.com/xu_zhibin/encryption
​#### 使用手册
使用手册

Maven坐标

支持Maven依赖安装,如果中央仓库(后续会上传)没有,则需要打包编译安装到本地仓库或私服(版本号为最新版本号):

<!-- 导入 starter 包-->
<dependency>
    <groupId>com.github.xzb617</groupId>
    <artifactId>encryption-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>
使用方法
  1. 引入 encryption-spring-boot-starter

    <dependency>
        <groupId>com.github.xzb617</groupId>
        <artifactId>encryption-spring-boot-starter</artifactId>
        <version>1.x.x</version>
    </dependency>
    
  2. 配置加密器使用的算法模式,其中configs的配置是根据不同算法模式有不同的配置项,参考:

    # 加密配置
    encryption:
      charset: 'UTF-8'
      algorithm: rsa_with_aes
      # 不同算法模式有不同的配置项
      configs:
        public-key: 'xxxxxxx'
        private-key: 'xxxxxxx'
        secret: 'xxxxxxx'
        iv: 'xxxxxxx'
    
  3. 在启动类或配置类上添加开启注解 @EnableEncryption

    @EnableEncryption
    @SpringBootApplication
    public class EncryptionSpringBootSampleApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(EncryptionSpringBootSampleApplication.class, args);
        }
    
    }
    
  4. 控制台打印出下面的信息就代表,框架可以正常使用了

    2022-xx-xx 23:07:39.782  INFO 14864 --- [           main] c.g.x.e.a.EncryptionAutoConfiguration    : Encryption has take effective successfully
    
入门案例
@RestController
@RequestMapping("/decryptParam")
public class DecryptParamController {

    /**
     * 测试 @DecryptParam 注解
     * @param intKey 
     * @param longKey
     * @param doubleKey
     * @param strKey
     * @param boolKey
     * @param dateKey
     * @return
     */
    @GetMapping("/index")
    public Result index(@DecryptParam(required = true, message = "intKey不能为空") Integer intKey,
                        @DecryptParam(required = true, message = "longKey不能为空") Long longKey,
                        @DecryptParam(required = true, message = "doubleKey不能为空") Double doubleKey,
                        @DecryptParam(required = true, message = "strKey不能为空") String strKey,
                        @DecryptParam(required = true, message = "boolKey不能为空") Boolean boolKey,
                        @DecryptParam(required = true, message = "dateKey不能为空") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date dateKey) {
        return Result.success("解密参数成功",
                String.format(
                    "intKey: %d, longKey: %d, doubleKey: %f, strKey: %s, boolKey: %s, dateKey: %s",
                    intKey, longKey, doubleKey, strKey, boolKey, dateKey
                )
        );
    }

}

更多的使用说明详见使用手册

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值