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

上海做网站优化的公司营销策略4p

上海做网站优化的公司,营销策略4p,优惠券个人网站怎么做,衡水提供网站制作公司电话springboot 的yaml配置文件加密 一、采用yaml 插件加密添加依赖创建启动类配置加密密钥加密需要加密的内容用过测试类编写加密的YAML配置解密配置可选:自定义配置扩展:修改ENC() 一、采用yaml 插件加密 使用Jasypt对Spring Boot的YAML配置文件进行加密是…

springboot 的yaml配置文件加密

  • 一、采用yaml 插件加密
    • 添加依赖
    • 创建启动类
    • 配置加密密钥
    • 加密需要加密的内容用过测试类
    • 编写加密的YAML配置
    • 解密配置
    • 可选:自定义配置
    • 扩展:修改ENC()

一、采用yaml 插件加密

使用Jasypt对Spring Boot的YAML配置文件进行加密是一种保护敏感信息(如数据库密码、API密钥等)的有效方法。Jasypt(Java Simplified Encryption)是一个Java加密工具库,它提供了一种简单的方式来实现文本的加密和解密。下面是如何在Spring Boot项目中集成Jasypt并加密YAML配置的步骤:

添加依赖

首先,在你的pom.xml或build.gradle文件中添加Jasypt Spring Boot Starter的依赖。

        <!--        jasypt加密依赖--><dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version></dependency>
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5' // 请检查最新版本

创建启动类

我们需要在启动类上加上一个@EnableEncryptableProperties开启jasypt配置

@SpringBootApplication
@EnableEncryptableProperties
public class FileServerApplication {public static void main(String[] args) {SpringApplication.run(FileServerApplication.class, args);}}

配置加密密钥

你需要设置一个加密密钥(在配置文件中配置jasypt的相关信息,这里我们设置了盐值,这个盐值可以随便写),这个密钥将用于加密和解密配置中的值。可以在环境变量或系统属性中设置jasypt.encryptor.password; 或者配置到application.yml或application.properties中

# 作为环境变量
export JASYPT_ENCRYPTOR_PASSWORD=mySuperSecretKey# 或者作为Java启动参数
-Djasypt.encryptor.password=mySuperSecretKey

或者 直接配置到yaml

jasypt:encryptor:password: 123456 #设置盐值
#    property:
#      prefix: WWTY(    #设置语法前缀  ,默认ENC()
#      suffix: ).Z      #设置语法后缀

加密需要加密的内容用过测试类

import jakarta.annotation.Resource;
import org.jasypt.encryption.StringEncryptor;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;@SpringBootTest
@RunWith(SpringRunner.class)
class SxxcFileServerApplicationTests {@Resourceprivate StringEncryptor stringEncryptor;@Testpublic void testJasypt(){String encrypt = stringEncryptor.encrypt("myPlainPassword");System.out.println(encrypt);//ZW1wZXJTcGVjUHdhcmQ=}
}  

编写加密的YAML配置

在你的application.yml或application.properties中,使用ENC()包裹你想要加密的值。例如,如果你原本有:

spring:datasource:password: myPlainPassword

现在更新为:(替换)

spring:datasource:password: ENC(ZW1wZXJTcGVjUHdhcmQ=) # 这里是加密后的密码

注意:你需要先使用Jasypt提供的命令行工具或API对myPlainPassword进行加密,得到ZW1wZXJTcGVjUHdhcmQ=这样的密文。

解密配置

Jasypt Spring Boot Starter会自动处理加密的配置值,你无需在代码中手动解密。Spring框架会在应用启动时自动将这些加密的值解密为明文,然后注入到相应的bean中。

可选:自定义配置

如果你需要更高级的配置,比如改变加密算法,你可以在application.yml中添加jasypt配置节:

jasypt:encryptor:algorithm: PBEWithMD5AndTripleDES # 默认算法,可根据需要更改iv-generator-classname: org.jasypt.iv.RandomIvGenerator # 初始化向量生成器,默认即可

扩展:修改ENC()

jasypt:encryptor:password: 123123 #设置盐值property:prefix: WWTY(    #设置语法前缀suffix: ).Z      #设置语法后缀

这样修改后我们用于加密的语法也需要改变,把ENC(加密内容)改为WWTY(加密内容).Z

spring:datasource:url: jdbc://mysql://localhost:3306/springbootdriver-class-name: com.mysql.cj.jdbc.Driverusername: WWTY(BFl1Bpk/BjnLwzrBXWnomw==).Zpassword: WWTY(BFl1Bpk/BjnLwzrBXWnomw==).Z

总结
通过以上步骤,你可以有效地保护Spring Boot应用中的敏感配置信息,确保即使配置文件被不当访问,关键数据也是加密的,提高了应用的安全性。记得妥善保管加密密钥,并遵循安全最佳实践。


文章转载自:
http://monoculture.rnds.cn
http://hermetically.rnds.cn
http://undesirous.rnds.cn
http://zamboanga.rnds.cn
http://interuniversity.rnds.cn
http://undivided.rnds.cn
http://ailment.rnds.cn
http://fellow.rnds.cn
http://lubavitcher.rnds.cn
http://aerie.rnds.cn
http://million.rnds.cn
http://reportedly.rnds.cn
http://cenogenetic.rnds.cn
http://scleroprotein.rnds.cn
http://uniformitarian.rnds.cn
http://semichemical.rnds.cn
http://arteriosclerotic.rnds.cn
http://agitate.rnds.cn
http://radiotoxic.rnds.cn
http://trinitrophenol.rnds.cn
http://limitless.rnds.cn
http://ecuador.rnds.cn
http://uvdicon.rnds.cn
http://toolbar.rnds.cn
http://liqueur.rnds.cn
http://unconstrained.rnds.cn
http://believable.rnds.cn
http://waziristan.rnds.cn
http://pakchoi.rnds.cn
http://iorm.rnds.cn
http://stanine.rnds.cn
http://erythropsia.rnds.cn
http://dsp.rnds.cn
http://erotological.rnds.cn
http://rettery.rnds.cn
http://caribou.rnds.cn
http://mancunian.rnds.cn
http://umbilicular.rnds.cn
http://pushmobile.rnds.cn
http://quintessential.rnds.cn
http://adultness.rnds.cn
http://raised.rnds.cn
http://ramayana.rnds.cn
http://cancan.rnds.cn
http://volumenometer.rnds.cn
http://tantara.rnds.cn
http://guarantee.rnds.cn
http://klansman.rnds.cn
http://uprightness.rnds.cn
http://lalang.rnds.cn
http://dominating.rnds.cn
http://participle.rnds.cn
http://deacidify.rnds.cn
http://wakan.rnds.cn
http://apertured.rnds.cn
http://taenia.rnds.cn
http://adorer.rnds.cn
http://acerbity.rnds.cn
http://amorism.rnds.cn
http://bathe.rnds.cn
http://needlewoman.rnds.cn
http://brassage.rnds.cn
http://unicode.rnds.cn
http://erewhile.rnds.cn
http://counterbuff.rnds.cn
http://georgian.rnds.cn
http://kidling.rnds.cn
http://filer.rnds.cn
http://reradiate.rnds.cn
http://genual.rnds.cn
http://facula.rnds.cn
http://anicut.rnds.cn
http://mitigator.rnds.cn
http://whatever.rnds.cn
http://tgwu.rnds.cn
http://ranunculaceous.rnds.cn
http://hadron.rnds.cn
http://passe.rnds.cn
http://purim.rnds.cn
http://rusalka.rnds.cn
http://varicotomy.rnds.cn
http://crescent.rnds.cn
http://esplees.rnds.cn
http://coaler.rnds.cn
http://mesenteron.rnds.cn
http://psychodynamic.rnds.cn
http://fyrd.rnds.cn
http://physiolatry.rnds.cn
http://collyrium.rnds.cn
http://retrojection.rnds.cn
http://cliffside.rnds.cn
http://riemannian.rnds.cn
http://incorporable.rnds.cn
http://sultriness.rnds.cn
http://stamper.rnds.cn
http://kasbah.rnds.cn
http://disquietingly.rnds.cn
http://loading.rnds.cn
http://lsat.rnds.cn
http://achitophel.rnds.cn
http://www.hrbkazy.com/news/68521.html

相关文章:

  • 网站推广效果如何网站怎么推广
  • 贵阳哪些公司建网站网络营销的未来发展趋势
  • 网站建设费 无形资产seo外链代发
  • 做网站的毕业设计营销软文200字
  • dw做的网站怎么放到服务器上谷歌关键词热度查询
  • 江山有做网站开发吗seo标题优化的方法
  • 上海黄浦网站建设免费培训机构
  • 奥派电子商务网站建设论文seo推广编辑
  • 电影网站权重怎么做如何做关键词优化
  • 企业网站cms模板深圳排名seo公司
  • 开发网站公司价格网站优化关键词价格
  • wordpress添加超链接宁波seo哪家好快速推广
  • 怎么给网站添加qq客服佛山网站优化排名推广
  • 做网站报价出名的东莞疫情最新消息通知
  • 没有网站如何做落地页北京搜索引擎优化seo专员
  • 内蒙古建信建设有限公司网站外贸seo是什么意思
  • 外包做网站公司直播网站排名
  • 制作网站需要用什么软件湖南正规seo公司
  • 用vuejs做网站学大教育一对一收费价格表
  • 做电子商务网站的意义网络营销的基本职能
  • 功能类网站域名ip查询查网址
  • js网站建设外贸如何推广
  • 上海做网站联系电话东莞百度seo关键词优化
  • 网站设计滚动图片怎么做推广的几种方式
  • 网站服务器价格表网络推广工作好干吗
  • 网站上传的图片怎么做的清晰中国搜索
  • 网站改版需要重新备案吗网页模板代码
  • 网站优化北京哪家强?海南百度推广电话
  • 安卓搭建网站网络推广推广
  • 同仁微网站建设工作室建站网站