Spring配置文件敏感数据加密

  1. 引入依赖
        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>3.0.5</version>
        </dependency>


  1. 启动项目指定加密盐:
jasypt:
  encryptor:
    password: \*\*\*\*\*

  1. 进行明文加密

controller加密类

package com.zhqc.cloud.wms.ob.controller;

import groovy.util.logging.Slf4j;
import org.jasypt.encryption.StringEncryptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/\*\*
 \* @author zdd
 \*/
@RestController
@RequestMapping("/encrypted")
@Slf4j
public class EncryptedController {

    private static final Logger log = LoggerFactory.getLogger(EncryptedController.class);
    @Resource
    private StringEncryptor stringEncryptor;

    @GetMapping("/encrypt/{str}")
    public void encrypted(@PathVariable("str") String str) {
        log.info("加密 password: ENC({})", stringEncryptor.encrypt(str));
    }

    @GetMapping("/decrypt/{str}")
## 最后

**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

**深知大多数网络安全工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

**因此收集整理了一份《2024年网络安全全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。**

![img](https://img-blog.csdnimg.cn/img_convert/b0fec649c73f955fe612a5d3616c62e0.png)

![img](https://img-blog.csdnimg.cn/img_convert/d8f4b2e0abf70f84a11880930e2191f1.png)

![img](https://img-blog.csdnimg.cn/img_convert/7be58b36f0de732c198ee6c5910459d7.png)

![img](https://img-blog.csdnimg.cn/img_convert/2b0d0934b1881fe88470212c37eb766b.png)

![img](https://img-blog.csdnimg.cn/img_convert/8d984b030cf128bbf7b488ebf2adb9fa.png)

 

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上网络安全知识点!真正的体系化!**

[**如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!**](https://bbs.csdn.net/topics/618653875)

**由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!**

618653875)

**由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!**

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值