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

网站的开发是使用什么技术网页推广怎么做

网站的开发是使用什么技术,网页推广怎么做,阿里云网站建设部署与发布,wordpress小程序搭建文章目录 前言一、集成 Jasypt1. pom 依赖2. yml 依赖 3. 加密工具类3. 使用二、常见问题1. application.yml 失效问题2. 配置热更新失败问题 前言 jasypt 官方地址:https://github.com/ulisesbocchio/jasypt-spring-boot Jasypt可以为Springboot加密的信息很多&a…

文章目录

  • 前言
  • 一、集成 Jasypt
    • 1. pom 依赖
    • 2. yml 依赖
  • 3. 加密工具类
  • 3. 使用
  • 二、常见问题
    • 1. application.yml 失效问题
    • 2. 配置热更新失败问题


前言

jasypt 官方地址:https://github.com/ulisesbocchio/jasypt-spring-boot

Jasypt可以为Springboot加密的信息很多,主要有:

  1. System Property 系统变量。
  2. Envirnment Property 环境变量。
  3. Command Line argument 命令行参数。
  4. Application.properties 应用配置文件。
  5. Yaml properties 应用配置文件。
  6. other custom property sources 其它配置文件。

一、集成 Jasypt

1. pom 依赖

<!-- jasypt(yml加密) -->
<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version>
</dependency>

2. yml 依赖

jasypt:encryptor:password: encpassword # 加密盐值(自定义)algorithm: PBEWithMD5AndDES # 加密算法(3.0.5以下版本默认PBEWithMD5AndDES,即DES加密算法-32位密文;3.0.5及以上版本默认PBEWITHHMACSHA512ANDAES_256,即AES加密算法-64位密文)iv-generator-classname: org.jasypt.iv.NoIvGenerator # 加密偏移生成器

3. 加密工具类

使用如下工具类,对密码进行加密获取密文。

import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;/*** jasypt(yml加密)工具** @author whiteen* @date 2024-06-20 00:00:00*/
@Slf4j
public class JasyptUtil {/*** DES加密** @param original 待加密内容* @param password 加密盐值* @return 加密密文* @author whiteen* @date 2024-06-20 00:00:00*/public static String encryptByDes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWithMD5AndDES");config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");encryptor.setConfig(config);// 加密return encryptor.encrypt(original);}/*** AES加密** @param original 待加密内容* @param password 加密盐值* @return 加密密文* @author whiteen* @date 2024-06-20 00:00:00*/public static String encryptByAes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");encryptor.setConfig(config);// 加密return encryptor.encrypt(original);}/*** DES解密** @param original 待解密内容* @param password 加密盐值* @return 加密明文* @author whiteen* @date 2024-06-20 00:00:00*/public static String decryptByDes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWithMD5AndDES");config.setIvGeneratorClassName("org.jasypt.iv.NoIvGenerator");encryptor.setConfig(config);// 解密return encryptor.decrypt(original);}/*** AES解密** @param original 待解密内容* @param password 加密盐值* @return 加密明文* @author whiteen* @date 2024-06-20 00:00:00*/public static String decryptByAes(String original, String password) {StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();// 设置盐值config.setPassword(password);config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");encryptor.setConfig(config);// 解密return encryptor.decrypt(original);}public static void main(String[] args) {// 待加密内容String original = "original";// 加密盐值String password = "encpassword";// DES加密String encryptedDes = encryptByDes(original, password);log.info("DES密⽂: {}", encryptedDes);// DES解密String decryptedDes = decryptByDes(encryptedDes, password);log.info("DES明⽂: {}", decryptedDes);// AES加密String encryptedAes = encryptByAes(original, password);log.info("AES密⽂: {}", encryptedAes);// AES解密String decryptedAes = decryptByAes(encryptedAes, password);log.info("AES明⽂: {}", decryptedAes);}}

3. 使用

password: ENC(${ORACLE_PWD:password})

二、常见问题

1. application.yml 失效问题

如果你的项目存在 boostrap.yml 配置文件,在引入 jasypt-spring-boot-starter 之后,发现 application.yml 与 application-dev.yml 配置没有生效,需要在 boostrap.yml 中设置 jasypt.encryptor.bootstrap 属性为 false,禁用对 boostrap 配置文件的加密支持,就可以解决 application.yml 与 application-dev.yml 配置失效的问题。

说明:
当 jasypt 和 springcloud 一起使用时,bootstrap 的配置会失效。追踪代码发现,spring 在启动 bootstrap 容器后,当把 bootstrap 容器的 environment 合并到子容器时,只同步了 OriginTrackedMapPropertySource 类型 BootstrapApplicationListener,此时所有的 PropertySource 都已经被包装为 EncryptablePropertySourceWrapper,所以会导致 bootstrap 的配置不会合并到子容器。

2. 配置热更新失败问题

在 yml 配置文件中设置环境变量报错。

参考 apollo 跟 jasypt-spring-boot-2.1.0.jar 不兼容问题: https://github.com/apolloconfig/apollo/issues/2162

升级 jasypt-spring-boot-starter 到 3.0.5 及以上版本可以解决配置热更新问题,再新增 algorithm 和 iv-generator-classname 两个配置即可:

<!-- jasypt(yml加密) -->
<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version>
</dependency>
jasypt:encryptor:password: encpassword # 加密盐值(自定义)algorithm: PBEWithMD5AndDES # 加密算法(3.0.5以下版本默认PBEWithMD5AndDES,即DES加密算法-32位密文;3.0.5及以上版本默认PBEWITHHMACSHA512ANDAES_256,即AES加密算法-64位密文)iv-generator-classname: org.jasypt.iv.NoIvGenerator # 加密偏移生成器

这样就可以在 yml 配置文件中设置环境变量:

password: ENC(${ORACLE_PWD:BBO5rGF40i+Sg5oG36MT5aEwpdrOe5f2})
http://www.hkea.cn/news/677879/

相关文章:

  • .net 购物网站开发源代码发布信息的免费平台
  • 自己做一网站大学生网络营销策划书
  • 关于网站建设的文章百度域名收录提交入口
  • 国人在线做网站推广图片大全
  • 郑州网站建设七彩科技四年级说新闻2023
  • 在什么网站上做自媒体seo整站怎么优化
  • 网站开发要注意安全性公司优化是什么意思
  • 河北邢台做移动网站开通网站需要多少钱
  • 天河网站建设多少钱淘宝关键词优化
  • 中型网站 收益关键词排名查询官网
  • 网站的弹窗是怎么做的谈谈对seo的理解
  • 广州网站制作费用宁波seo外包哪个品牌好
  • 河南高端网站建设广州网站优化页面
  • 企业可以备案几个网站南昌seo实用技巧
  • 网站用什么布局专业网站建设公司
  • 公司网站怎么做分录it培训机构学费一般多少
  • 如何将自己做的网页做成网站绍兴seo
  • 河南省住房与城乡建设厅网站首页怎么做属于自己的网站
  • 移动端网站开发推广效果最好的平台
  • 用二级页面做网站的源代码自助建站系统破解版
  • 网站上怎么做动画广告推广策略包括哪些内容
  • 广州网站优化公司大亚湾发布
  • 广州网站开发招聘百度经验悬赏令
  • 吴江建设局网站郑州粒米seo外包
  • 建设工程合同纠纷与劳务合同纠纷seo培训教程视频
  • 找网站建设公司哪家最好沈阳市网站
  • sh域名做的好的网站什么是营销
  • 网站平台怎么做推广一站式网络推广服务
  • 百度对新网站排名问题兰州seo快速优化报价
  • 网站建设常用代码湘潭网络推广