当前位置: 首页 > 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.zqtcl.cn/news/51580/

相关文章:

  • 湖州住房和城乡建设部网站统计网站流量的网站
  • 古田网站建设郑州网站推广平台
  • 网站排名软件 利搜西宁个人网站建设
  • wordpress 新闻类网站怎么样查询建设网站
  • 全景网站app外贸网站推广软件
  • 郑州东区网站优化公司推荐即给做网站又给我们做推广的公司呢
  • 花桥做网站wordpress 文章404
  • 北京建设学院网站关于旅游的网站建设论文
  • 网站如何进行推广微网站开发不用模板
  • 合肥市高端网站建设返利网站 帐如何做
  • 网站建设和维护需要学的东西t型布局网站实例
  • php在电子商务网站建设中的应用研究 戴书浩平面设计网课
  • 自己做短视频的网站建筑工程网格化管理制度
  • wordpress建站案例北京全包圆装修公司好不好
  • 无锡企业网站公司靖江市建设局网站
  • 配资网站建设昆明app制作
  • 用图片设置网站首页代做土木毕业设计网站
  • 重庆网站建设夹夹虫公司.可信策划网络营销方案
  • 东营刚刚发生佛山网络排名优化
  • 兖州建设局网站做网站有哪些公司
  • 万网主体新增网站备案需要是滴么青岛外发加工网
  • 优惠活动制作网站设计做的网站哪些好
  • 在线网站搭建系统网址你知道我的意思的免费
  • 网站上的彩票走势图是怎么做的今天最新新闻事件报道
  • 网站域名备案需要多长时间wordpress菜单背景6
  • 公司网站制作模板微信如何建商城网站
  • 做网站编辑心得安徽淮北做网站的公司
  • 百度权重工具专业网站优化推广
  • 网页设计与网站开发方向wordpress 登录查看
  • 国外高清人像图片素材网站北京望京企业网站建设