当前位置: 首页 > news >正文

成都多语种网站建设建设部网站焊工证件查询

成都多语种网站建设,建设部网站焊工证件查询,深圳商城软件开发公司,wordpress网页搭建报名表下面是在Spring Boot项目中对属性文件中的账号密码进行加密的完整步骤#xff0c;以MySQL的用户名为root#xff0c;密码为123321为例#xff1a; 步骤1#xff1a;引入Jasypt依赖 在项目的pom.xml文件中#xff0c;添加Jasypt依赖#xff1a; dependency…下面是在Spring Boot项目中对属性文件中的账号密码进行加密的完整步骤以MySQL的用户名为root密码为123321为例 步骤1引入Jasypt依赖 在项目的pom.xml文件中添加Jasypt依赖 dependencygroupIdcom.github.ulisesbocchio/groupIdartifactIdjasypt-spring-boot-starter/artifactIdversion3.0.3/version /dependency步骤2配置加密密码 在src/main/resources/application.yml或application.properties中配置Jasypt的加密密码。将其替换为自己的密匙例如 jasypt:encryptor:password: lfsun666确保将lfsun666替换为自己的密匙。 步骤3加密属性值 在application.yml或application.properties spring:datasource:username: rootpassword: 123321步骤4创建MyJasyptUtil类 创建一个用于加密和解密属性值的实用类例如MyJasyptUtil。这个类将使用Jasypt的BasicTextEncryptor进行属性的加密和解密。以下是一个示例 import org.jasypt.encryption.StringEncryptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component;/*** 用于加密和解密属性值的实用类这个类将使用Jasypt的BasicTextEncryptor进行属性的加密和解密。*/ Component public class MyJasyptUtil {private final StringEncryptor stringEncryptor;Autowiredpublic MyJasyptUtil(StringEncryptor stringEncryptor) {this.stringEncryptor stringEncryptor;}public String encrypt(String input) {return stringEncryptor.encrypt(input);}public String decrypt(String input) {return stringEncryptor.decrypt(input);} }步骤5在应用中使用MyJasyptUtil 使用MyJasyptUtil类来加密和解密属性值。示例 import com.lfsun.demolfsunstudyjasypt.util.MyJasyptUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service;Service public class MyJasyptService {Value(${spring.datasource.username})private String username;Value(${spring.datasource.password})private String password;Autowiredprivate MyJasyptUtil myJasyptUtil;/*** 保存加密后的凭据。*/public void saveCredentials() {String encryptedUsername myJasyptUtil.encrypt(username);String encryptedPassword myJasyptUtil.encrypt(password);System.out.println(加密后的用户名和密码: encryptedUsername : encryptedPassword);}/*** 检索解密后的凭据。*/public void retrieveCredentials() {String decryptedUsername myJasyptUtil.decrypt(username);String decryptedPassword myJasyptUtil.decrypt(password);System.out.println(解密后的用户名和密码: decryptedUsername : decryptedPassword);} }步骤6测试 拿到加密后的用户名和密码然后替换到application.yml import com.lfsun.demolfsunstudyjasypt.service.MyJasyptService; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan;SpringBootApplication public class DemoLfsunStudyJasyptApplication {public static void main(String[] args) {/*** 在应用启动后立即创建了一个 MyJasyptService 实例并调用了 saveCredentials 方法。* 这并不是正确的方式来获取 Spring 管理的 Bean。** Spring Boot 应用的 Bean 生命周期和管理是由 Spring 容器控制的不应该手动创建 Bean 实例。** 应该在 Spring 容器初始化后使用 Spring 框架来获取 MyJasyptService Bean 并调用相应的方法。*//*SpringApplication.run(DemoLfsunStudyJasyptApplication.class, args);MyJasyptService myJasyptService new MyJasyptService();myJasyptService.saveCredentials();*/// 正确的方式ConfigurableApplicationContext context SpringApplication.run(DemoLfsunStudyJasyptApplication.class, args);MyJasyptService myJasyptService context.getBean(MyJasyptService.class);// 拿到加密后的用户名和密码myJasyptService.saveCredentials();// 用加密后的用户名和密码去覆盖真实的密码// myJasyptService.retrieveCredentials();}}取出密码 // 拿到加密后的用户名和密码// myJasyptService.saveCredentials();// 用加密后的用户名和密码去覆盖真实的密码myJasyptService.retrieveCredentials(); 即可 通过这些步骤可以在Spring Boot项目中对属性文件中的账号密码进行加密提高安全性。确保保护好加密密码jasypt.encryptor.password以防止数据泄漏。
http://www.pierceye.com/news/51580/

相关文章:

  • 网站开发要学习路线软件开发流程和规范
  • 如何验证网站h5开发网站优点
  • 姜堰网网站做湲网站
  • 微信小程序商城源码绍兴seo推广
  • wordpress程序重装wordpress数据库优化插件
  • 最好的淘宝客网站陕西一建考试最新消息
  • saas电商建站系统佛山外贸网站建设方案
  • 济南 手机网站制作合肥网络推广平台
  • 装修设计图网站排名电子商务平台在家能干吗
  • 建设工程方面的资料在哪个网站下载比较方便专业建设网站企业
  • 开平市网站建设互联网营销师证书好考吗
  • 网站建设哪家最好用电商网站建设c微fzsszai
  • 网站做我女朋友北京seo代理商
  • 没有数据库的网站保定网站建设平台分析
  • 网站建设公司巨头网站做seo需要些什么
  • 网站对比app还有优势吗郑州企业服务公司
  • dede 网站名称织梦网站排行榜
  • 猪八戒网可以做网站吗黑龙江建设网官网住房和城乡厅官网
  • 赣州网站优化制作wordpress myqaptcha
  • 农业公司怎样建立网站网站域名被重定向
  • 电子商务网站规划与建设摘要泉州wap网站制作
  • 滁州网站开发公司电话wordpress汉字后缀图片不显示
  • 凡科建站做网站需要几天近一周财经新闻热点
  • 郑州市城乡建设局证书查询seo网站建设规划
  • 苏州高端模板建站WordPress潮流媒体主题
  • 博物馆网站页面设计说明营销广告网站
  • 新开传奇网站单职业室内效果图网站
  • 简洁物流网站模板免费下载沈阳网站建设聚艺科技
  • 网站多语言 设计如何做转运网站
  • 网站未建设的情况说明书上海市安全建设监理协会网站