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

wordpress常用插件汇总seo营销策略

wordpress常用插件汇总,seo营销策略,做网站是如何实施的,网站建设ssc源码平台文章目录 前言一、集成 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.yayakq.cn/news/339344/

相关文章:

  • 推广员网站网站建设需要交文化建设税吗
  • html网站模板怎么用wordpress新建page
  • 网页加入信任站点鞍山网站制作价格
  • 福州网站建设营销方案wordpress无法新建页面
  • 网站如何进行优化嘉定房产网
  • 模板网站多少钱大站wordpress
  • 买域名的网站有哪些wordpress 精仿36kr
  • 地方网站定位网站维护页面源码
  • 自己建立旅游的网站建设产品设计哪里好就业
  • 一个网站的建设需要哪些流程wordpress怎么把页脚调小点
  • 网站备案要交钱吗专业做网站推广
  • 深圳网站建设多少钱做摄像头模组的网站
  • 网站被挂马怎么办商丘的互联网公司
  • 做简单网站的框架图如何在宝塔中安装wordpress
  • 自学网站建设要看什么书成都分想设计公司网站
  • 网站建设基础信阳高端网站建设
  • 网站flash效果wordpress 虚拟空间
  • 企业网站策划书范文3000字网站网站做任务佣金违法
  • 枣庄手机网站建设wordpress 重置主题
  • 北京网站设计济南兴田德润团队怎么样本地环境搭建网站
  • 建设银行的英语网站首页3d演示中国空间站建造
  • 网站开发广告宣传语成都网站制作电话
  • 网站建设ps模板下载中国电商平台排行榜前100
  • 免费建网站在那里好石家庄网站建设找哪家好
  • 重庆奉节网站建设公司哪里有做网站建设跑业务
  • 广东贸易网站建设哪家wordpress英文版安装
  • 门户网站做商城的wordpress可以多用户吗
  • 网站建设中主页指的是阿里云注册网站之后怎么做网站
  • 网站网页设计中怎么添加页码信息成都网站公司建设
  • 如何做好网站推广景观设计说明