springboot禁用数据库数据库加密

##maven依赖
&!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter --&
&dependency&
&groupId&com.github.ulisesbocchio&/groupId&
&artifactId&jasypt-spring-boot-starter&/artifactId&
&version&1.8&/version&
&/dependency&
##配置加密参数
encryptor:
password: 123456
##使用加密
show-sql: true
hibernate:
ddl-auto: update
datasource:
url: jdbc:postgresql://localhost:5432/postgres
driver-class-name: org.postgresql.Driver
username: postgres
password: ENC(EbfYkitulv73I2p0mXI50JMXoaxZTKJ7)
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: true
##加密密码
@Autowired
StringEncryptor stringE
public void encryptPwd() {
String result = stringEncryptor.encrypt(&yourpassword&);
System.out.println(result);
& 著作权归作者所有
人打赏支持
码字总数 511472
感谢,正好要找这个东西。
评论删除后,数据将无法恢复
前言: 在实际开发中,一些关键的信息肯定是要加密的,否则就太不安全了。比如连接数据库的用户名和密码,一般就需要加密。接下来就看看spring项目和spring boot项目中分别是如何加密这些信息...
maven依赖 &!-- 加密工具 --& 配置加密参数(可以理解为加密的salt) jasypt: encryptor: password: 123456(这个可以随便设置的,每次设置时数据库的接连驱动要是明文(也就是不加密的,否则运...
背景 对于前两种分别存在的问题 有其他组件可以负责处理 https://github.com/ulisesbocchio/jasypt-spring-boot Jasypt Spring Boot provides Encryption support for property sources in S......
springBoot项目构建 Spring多模块项目的构建 1.使用Idea构建一个Springboot项目 File--&new--&project--&springInitializr--&(NEXT) 2.主项目pom中添加依赖 ~ org.springframework.bootspri......
JavionXiong
说明springboot版本2.0.3 一、 介绍
Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架。它提供了一组可以在Spring应用上下文中配置的B...
没有更多内容
加载失败,请刷新页面
1.背景 说起应用分层,大部分人都会认为这个不是很简单嘛 就controller,service, mapper三层。看起来简单,很多人其实并没有把他们职责划分开,在很多代码中,controller做的逻辑比service还...
一、MultipartEntityBuilder 实现文件上传步骤 在HttpCient4.3之后上传文件主要使用的类是位于org.apache.http.entity.mime下的MultipartEntityBuilder(原先的MultipartEntity已经基本弃用了...
xiaomin0322
源码在这里https://github.com/zdy1988/vue-jstree 我是vue-cli建的项目 npm install vue-jstree --save 组件里这样写 import VJstree from 'vue-jstree';import axios from "axios";exp......
iOS精选源码 JPLiquidLayout 简单易用的流式布局 labelGroupAndStreamSwift---标签分组,单选,多选 iOS采用UITableView和UIScrollView来实现Excel、课程表的上下左右... 3D Touch打开控制器...
1.到https://www.kernel.org/ 下载需要的内核版本 2.上传到操作系统 3.解压到/usr/src目录下 比如3.19内核 tar -xvf linux-3.19.tar.xz -C /usr/src 4.创建连接 cd /usr/src ln -sv /usr/sr...
tututu_jiang
没有更多内容
加载失败,请刷新页面
文章删除后无法恢复,确定取消删除此文章吗?
亲,自荐的博客将通过私信方式通知管理员,优秀的博客文章审核通过后将在博客推荐列表中显示
确定推荐此文章吗?
确定推荐此博主吗?
聚合全网技术文章,根据你的阅读喜好进行个性推荐
指定官方社区
深圳市奥思网络科技有限公司版权所有Spring Boot -- 配置文件内容加密jasypt
作者:用户
本文讲的是Spring Boot -- 配置文件内容加密jasypt,
使用过SpringBoot配置文件的朋友都知道,资源文件中的内容通常情况下是明文显示,安全性就比较低一些。打开application.properties或application.yml,比如mysql登陆密码,redis
使用过SpringBoot配置文件的朋友都知道,资源文件中的内容通常情况下是明文显示,安全性就比较低一些。打开application.properties或application.yml,比如登陆密码,redis登陆密码以及第三方的密钥等等一览无余,这里介绍一个加解密组件,提高一些属性配置的安全性。
jasypt由一个国外大神写了一个springboot下的工具包,下面直接看代码:
1、maven依赖引入:
view plain
&!-- https://mvnrepository.com/artifact/com.hub.ulisesbocchio/jasypt-spring-boot-starter --&
&dependency&
&groupId&com.github.ulisesbocchio&/groupId&
&artifactId&jasypt-spring-boot-starter&/artifactId&
&version&1.14&/version&
&/dependency&
2、application.properties配置文件中增加如下内容(加解密时使用):
view plain
jasypt.encryptor.password=EbfYkitulv73I2p0mXI50JMXoaxZTKJ7
3、里面main方法或测试生成秘钥:
view plain
//这是JUnit的注解,通过这个注解让SpringJUnit4ClassRunner这个类提供Spring测试上下文。
@RunWith(SpringJUnit4ClassRunner.class)
//这是Spring Boot注解,为了进行集成测试,需要通过这个注解加载和配置Spring应用上下
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
public class EncryptorTest {
@Autowired
public void getPass() {
String name = encryptor.encrypt("DBusername");
String password = encryptor.encrypt("DBpassword");
System.out.println(name+"----------------");
System.out.println(password+"----------------");
Assert.assertTrue(name.length() & 0);
Assert.assertTrue(password.length() & 0);
4、将上面生成的name和password替换配置文件中的数据库账户和密码,替换后如下:
view plain
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://1.1.1.1:3306/xxxx?characterEncoding=utf8&useSSL=true
spring.datasource.username=ENC(zj4OUZ3/mmHV0JOgCdg8qQ==)
spring.datasource.password=ENC(UBtTQGk1xbdmhff+UUoT6g==)
简单四步完成加密操作。。。。。。。。。。。
以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索spring
,以便于您获取更多的相关知识。
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率
40+云计算产品,6个月免费体验
稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一
云服务器9.9元/月,大学必备
云栖社区(yq.aliyun.com)为您免费提供相关信息,包括
,所有相关内容均不代表云栖社区的意见!&nbsp>&nbsp
&nbsp>&nbsp
&nbsp>&nbsp
spring boot 配置数据库加密
摘要:1.pom.xml文件中引入com.github.ulisesbocchiojasypt-spring-boot-starter1.162.在windows命令行调用java-cpG:/maven/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jarorg.jasypt.intf.cli.JasyptPBEStringEncryptionCLIinput=&123456&password=aidan1234
1.pom.xml 文件中引入
com.github.ulisesbocchio
jasypt-spring-boot-starter
2.在windows命令行调用java -cp G:/maven/repository/org/jasypt/jasypt/1.9.2/jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input=&123456& password=aidan123456 algorithm=PBEWithMD5AndDES
input=数据库链接密码
password=加密字段。随意设置
algorithm=算法
执行后有以下输出:
----ENVIRONMENT-----------------
Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.131-b11
----ARGUMENTS-------------------
algorithm: PBEWithMD5AndDES
input: 123456
password: aidan123456
----OUTPUT----------------------
f9H36hfe5AnLkZrfUBSPQg==3.在spring boot的配置文件中加入以下配置spring.datasource.url=jdbc:mysql://localhost:3306/dbName
spring.datasource.username=root
jasypt.encryptor.password=aidan123456
spring.datasource.password=ENC(f9H36hfe5AnLkZrfUBSPQg==)
spring.datasource.driver-class-name=com.mysql.jdbc.Driver4.启动项目即可
https://www.ricston.com/blog/encrypting-properties-in-spring-boot-with-jasypt-spring-boot/
https://www.ricston.com/blog/encrypting-properties-in-spring-boot-with-jasypt-spring-boot/
http://www.cnblogs.com/zz0412/p/jasypt-001.html
https://github.com/ulisesbocchio/jasypt-spring-boot
以上是的内容,更多
的内容,请您使用右上方搜索功能获取相关信息。
若你要投稿、删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内给你回复。
新用户大礼包!
现在注册,免费体验40+云产品,及域名优惠!
云服务器 ECS
可弹性伸缩、安全稳定、简单易用
&40.8元/月起
预测未发生的攻击
&24元/月起
你可能还喜欢
你可能感兴趣
阿里云教程中心为您免费提供
spring boot 配置数据库加密相关信息,包括
的信息,所有spring boot 配置数据库加密相关内容均不代表阿里云的意见!投稿删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内答复
售前咨询热线
支持与服务
资源和社区
关注阿里云
International使用过SpringBoot配置文件的朋友都知道,资源文件中的内容通常情况下是明文显示,安全性就比较低一些。打开application.properties或application.yml,比如mysql登陆密码,redis登陆密码以及第三方的密钥等等一览无余,这里介绍一个加解密组件,提高一些属性配置的安全性。
jasypt由一个国外大神写了一个springboot下的工具包,下面直接看代码:
1、maven依赖引入:[html]
2、application.properties配置文件中增加如下内容(加解密时使用):[html]
3、里面main方法或测试生成秘钥:[java]
4、将上面生成的name和password替换配置文件中的数据库账户和密码,替换后如下:[html]
简单四步完成加密操作。。。。。。。。。。。
使用jasypt对springboot的datasource密码加密
dependency&
groupId&com.github.ulisesbocchiogroupId&
artifactId&jasypt-spring-boot...
SpringBoot实战(二)——配置文件内容加密jasypt
使用过SpringBoot配置文件的朋友都知道,资源文件中的内容通常情况下是明文显示,安全性就比较低一些。打开application.properties或application.yml,比如...
SpringBoot实现数据库密码的加密操作
com.github.ulisesbocchio
jasypt-spring-boot-starter
通过dos执行如下命令:java -cp
D:\maven_r...
使用jasypt加密Spring Boot应用中的敏感配置
欢迎访问 陈同学博客原文
jasypt-spring-boot on github
本文讲述了在Spring Boot/Spring Cloud应用中使用jasypt来加密proper...
jasypt的使用和获取jdk支持的密码学算法
* APDPlat - Application Product Development Platform
* Copyright (c) 2013, ...
Spring 中使用jasypt对配置文件(.properties)中密码加密
spring配置中经常使用placeholder来加载一个应用配置文件(.properties),但是其中的各种密码以明文显示出来总该是不好。
不过可以利用jasypt这个框架来扩展这个加密功能,需...
springboot(14)配置文件加密解密
jasypt-spring-boot
更多内容请访问http://lxgandlz.cn本文讲述Spring Boot整合Spring Security在方法上使用注解实现权限控制,使用自定义UserDetailService,从MySQ...
spring boot 配置数据库加密
本文目的:使用springBoot+springSecurity 用户授权验证权限功能,对用户的登录密码使用MD5 加密。本文基于我的博客:springboot+mybatis+SpringSecur...
没有更多推荐了,7.5k 次阅读
&!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter --&
&dependency&
&groupId&com.github.ulisesbocchio&/groupId&
&artifactId&jasypt-spring-boot-starter&/artifactId&
&version&1.8&/version&
&/dependency&
配置加密参数
encryptor:
password: 123456
show-sql: true
hibernate:
ddl-auto: update
datasource:
url: jdbc:postgresql://localhost:5432/postgres
driver-class-name: org.postgresql.Driver
username: postgres
password: ENC(EbfYkitulv73I2p0mXI50JMXoaxZTKJ7)
validation-query: SELECT 1
test-while-idle: true
test-on-borrow: true
@Autowired
StringEncryptor stringE
public void encryptPwd() {
String result = stringEncryptor.encrypt("yourpassword");
System.out.println(result);
1 收藏&&|&&7
分享到微博?
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。

我要回帖

更多关于 springboot数据库 的文章

 

随机推荐