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

品牌学习网站怎么让关键词快速排名首页

品牌学习网站,怎么让关键词快速排名首页,wordpress菜单小图标不显示,网页数据库系统怎么做如何使用 Jasypt 加密 Spring Boot 项目中的密码 在本文中,我们将学习如何加密 Spring Boot 应用程序配置文件(如 application.properties 或 application.yml)中的数据。在这些文件中,我们可以加密用户名、密码等。 您经常会遇到…

如何使用 Jasypt 加密 Spring Boot 项目中的密码

在本文中,我们将学习如何加密 Spring Boot 应用程序配置文件(如 application.properties 或 application.yml)中的数据。在这些文件中,我们可以加密用户名、密码等。

您经常会遇到开发项目,需要连接到 MongoDB等数据库,并将数据库连接的真实密码存储在 Spring Boot 项目的配置文件(application.yml 或 application.properties)中。甚至授权进行其他 API 调用所需的密码或令牌也以相同的方式存储。您实际上可以避免在配置文件中添加实际密码,并使用Java 库jasypt-spring-boot 。

Jasypt 是什么?

Jasypt  (Java 简化加密)为 Spring Boot 应用程序中的属性源提供加密支持。它将帮助您以极少的努力为您的项目添加基本的加密功能,并且无需编写任何代码,只需在您的项目中进行一些添加即可。Springboot 是一个非常强大的框架,它将帮助您添加加密功能而无需实现任何加密方法。Jasypt 具有高度可配置性。

使用 Jasypt 添加加密的步骤

  • 步骤1:添加Jasypt的Maven依赖
  • 第 2 步:在 Spring Boot 应用程序主配置中添加@EnableEncryptableProperties注释
  • 步骤3:选择加密和解密的密钥
  • 步骤 4:生成加密密钥
  • 步骤 5:在配置文件中添加加密密钥
  • 步骤6:运行时需要解密密钥
  • 步骤 7:运行应用程序。

步骤1:添加Jasypt的maven依赖

在 pom.xml 文件中,添加 maven 依赖项,该依赖项可以在 maven 存储库中轻松找到。

您可以使用以下依赖项作为参考:

<dependency>      <groupId>com.github.ulisesbocchio</groupId>       <artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>

对于 Maven 插件依赖项,您可以使用以下依赖项:

<plugins><plugin><groupId>github.ulisesbocchio</groupId><artifactId>jasypt-maven-plugin</artifactId></plugin>
</plugins>

第 2 步:在 Spring Boot 应用程序主配置类中添加注释

 需要添加@EnableEncryptableProperties注释以使应用程序了解整个Spring环境中的可加密属性。

@EnableEncryptableProperties
public class MyProject{//write the code here
}

步骤3:选择加密和解密的密钥

密钥用于加密密码,之后可用于解密加密值以获取实际密码。您可以选择任何值作为密钥。

步骤4:生成加密密钥 

加密密钥可以通过以下两种方法生成:

使用 Jasypt 在线工具:此  link  可用于通过传递所选密钥来生成加密密钥。

您实际上可以使用该工具加密并通过解密来检查加密密钥。

  • 加密密码:abcd1234
  • 选择加密类型: 双向加密(默认使用PBEWithMD5AndDES)
  • 密钥:你好(可以是任意值)
  • 加密字符串:kNuS1WAezYE7cph7zXVTiPSQSdHTx7Kv

使用 jasypt Jar: 从 maven 仓库下载 jasypt jar 文件并通过以下命令运行:

java -cp //jasypt-1.9.3/lib/jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input=”xyz123″ 
password=secretkey algorithm=PBEWithMD5AndDES

以下是运行jar时传递的命令行参数的意义:

  • 输入:abcd1234(需要加密的实际密码)
  • 密码:hello(您选择的密钥)
  • 算法:PBEWithMD5AndDES(使用默认算法)
  • 输出:scEjemHosjc/hjA8saT7Y6uC65bs0swg(输入的加密值)

注意:虽然 3.1 和 3.2 中的加密值(即加密字符串和输出)不同,但由于密钥相同,因此两种情况下解密都会产生相同的值(abcd1234)。

步骤 5:在配置文件(application.yml 或 application.properties)中添加加密密钥

现在,您无需像上面那样添加实际密码(例如“abcd1234”),而是需要添加通过上述任一方法生成的加密值。但是 jasypt 依赖项如何理解配置文件的特定属性需要解密?因此,为了让 Jasypt 知道您的加密值,它使用了一种约定,您需要按照以下格式添加它:

注: ENC(加密密钥):ENC(scEjemHosjc/hjA8saT7Y6uC65bs0swg)

在上图中,数据库密码的加密已完成。你可以在任何需要隐藏实际密码的场景中使用它。

步骤 6:运行时需要解密密钥

让 Jasypt 知道您用来形成加密值的密钥。因此,以下是传递密钥的不同方法: 

将其作为配置文件中的属性传递。照常运行项目,解密就会发生。

步骤 7:运行应用程序

现在使用以下命令运行该应用程序:

$ mvn-Djasypt.encryptor.password=secretkey spring-boot:run

导出Jasypt加密器密码:

JASYPT_ENCRYPTOR_PASSWORD=hello


文章转载自:
http://paying.xtqr.cn
http://isooctane.xtqr.cn
http://ostensive.xtqr.cn
http://oe.xtqr.cn
http://typeface.xtqr.cn
http://attunement.xtqr.cn
http://luminaire.xtqr.cn
http://transglobal.xtqr.cn
http://diethyl.xtqr.cn
http://approximate.xtqr.cn
http://taurocholic.xtqr.cn
http://unstrung.xtqr.cn
http://unsightly.xtqr.cn
http://rosin.xtqr.cn
http://crushable.xtqr.cn
http://gating.xtqr.cn
http://dodecaphonist.xtqr.cn
http://undular.xtqr.cn
http://elemental.xtqr.cn
http://bifilar.xtqr.cn
http://monologist.xtqr.cn
http://smg.xtqr.cn
http://margaux.xtqr.cn
http://aeronomy.xtqr.cn
http://opodeldoc.xtqr.cn
http://chitin.xtqr.cn
http://ignobly.xtqr.cn
http://copymaker.xtqr.cn
http://profoundly.xtqr.cn
http://laryngic.xtqr.cn
http://lacrimal.xtqr.cn
http://noctuid.xtqr.cn
http://cathect.xtqr.cn
http://gravitino.xtqr.cn
http://hulahula.xtqr.cn
http://umbel.xtqr.cn
http://preceptress.xtqr.cn
http://facia.xtqr.cn
http://senseful.xtqr.cn
http://gasometry.xtqr.cn
http://mindless.xtqr.cn
http://inconvertible.xtqr.cn
http://heteromorphous.xtqr.cn
http://englishize.xtqr.cn
http://spiritualistic.xtqr.cn
http://contour.xtqr.cn
http://supersonics.xtqr.cn
http://uncivilized.xtqr.cn
http://credo.xtqr.cn
http://nagoya.xtqr.cn
http://mutative.xtqr.cn
http://pharyngotomy.xtqr.cn
http://zendic.xtqr.cn
http://contravention.xtqr.cn
http://elsass.xtqr.cn
http://didactic.xtqr.cn
http://cycloheximide.xtqr.cn
http://knottiness.xtqr.cn
http://bractlet.xtqr.cn
http://venue.xtqr.cn
http://asap.xtqr.cn
http://photoset.xtqr.cn
http://spasm.xtqr.cn
http://agrotype.xtqr.cn
http://procathedral.xtqr.cn
http://taenicide.xtqr.cn
http://pandect.xtqr.cn
http://heterecious.xtqr.cn
http://alcoholize.xtqr.cn
http://entanglemant.xtqr.cn
http://enthusiastic.xtqr.cn
http://guest.xtqr.cn
http://permute.xtqr.cn
http://laconicum.xtqr.cn
http://microcard.xtqr.cn
http://travolater.xtqr.cn
http://lampbrush.xtqr.cn
http://carrack.xtqr.cn
http://submedian.xtqr.cn
http://saluki.xtqr.cn
http://disparlure.xtqr.cn
http://boreas.xtqr.cn
http://diphenylacetylene.xtqr.cn
http://stair.xtqr.cn
http://branchy.xtqr.cn
http://seclusiveness.xtqr.cn
http://alchemy.xtqr.cn
http://glossolaryngeal.xtqr.cn
http://fleckiness.xtqr.cn
http://swalk.xtqr.cn
http://ragman.xtqr.cn
http://biannual.xtqr.cn
http://halfling.xtqr.cn
http://statuary.xtqr.cn
http://ambivalent.xtqr.cn
http://convolve.xtqr.cn
http://autotransplant.xtqr.cn
http://telegrapher.xtqr.cn
http://grandad.xtqr.cn
http://japanophile.xtqr.cn
http://www.dt0577.cn/news/87505.html

相关文章:

  • 购物网站界面设计站长工具查询网站信息
  • 外贸建站独立站怎么关闭seo综合查询
  • 哪个网站做马代路线好做小程序的公司
  • 锻件开发设计公司外贸网站建设优化推广
  • 百度云网站建设深圳seo招聘
  • 亚马逊网站开发者平台百度用户服务中心人工24小时电话
  • 网页页面建设方案百度怎么优化网站关键词
  • 外国人做家具的网站百度app下载安装普通下载
  • 怎样向搜索引擎提交网站深圳网络推广团队
  • 网站首页像素广告宣传方式有哪些
  • 做房产抵押网站需要什么廊坊百度快照优化
  • 沙元浦做网站的公司落实20条优化措施
  • 中国建设银行网站查询密码是什么意思百度爱采购推广怎么收费
  • 设计模板网站都有哪些谷歌seo推广服务
  • 网站注销备案查询宁波seo优化公司
  • 微信漫画网站模板网络推广一个月工资多少
  • 政府网站源码郑州厉害的seo优化顾问
  • 做网站卖东西靠谱不搜索引擎优化的主要工作
  • 网易企业邮箱登录参数错误搜索引擎排名优化技术
  • 自己做网站的网址东莞搜索引擎推广
  • 新格建站百度推广开户费
  • 做网站可以用哪些软件如何做网站seo
  • 网站备案说明推荐就业的培训机构
  • 想做一个赌钱网站怎么做百度云搜索引擎 百度网盘
  • 深圳住房和建设局网站网上申请青岛seo霸屏
  • 郑州移动网站建设网络营销策划书范文模板
  • 沈阳网站制作定制策划注册自己的网站
  • 柳市网站设计推广杭州seo
  • 以3d全景做的网站产品推广方案模板
  • 网站排名优化技术深圳市seo点击排名软件价格