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

知乎网站内容建设的逻辑网站收录提交入口官网

知乎网站内容建设的逻辑,网站收录提交入口官网,pc端网站优缺点,c做网站文章目录 一、介绍二、Spring集成1、 Maven依赖2、application.xml的配置3、配置文件使用4、方法加密 二、SpringBoot集成1、 Maven依赖2、 Java Bean配置jasyptStringEncryptor3、配置文件使用4、Bean使用加密字段自动解密 一、介绍 Jasypt is a java library which allows th…

文章目录

  • 一、介绍
  • 二、Spring集成
    • 1、 Maven依赖
    • 2、application.xml的配置
    • 3、配置文件使用
    • 4、方法加密
  • 二、SpringBoot集成
    • 1、 Maven依赖
    • 2、 Java Bean配置jasyptStringEncryptor
    • 3、配置文件使用
    • 4、Bean使用加密字段自动解密

一、介绍

Jasypt is a java library which allows the developer to add basic encryption capabilities to his/her projects with minimum effort, and without the need of having deep knowledge on how cryptography works.
Jasypt是一个Java库,它允许开发人员以最小的努力为他/她的项目添加基本的加密功能,而无需深入了解密码学的工作原理。

  • High-security, standards-based encryption techniques, both for unidirectional and bidirectional encryption. Encrypt passwords, texts, numbers, binaries…
    基于标准的高安全性加密技术,适用于单向和双向加密。加密密码,文本,数字,二进制文件…
  • Transparent integration with Hibernate.
    完美地与 Hibernate 集成。
  • Suitable for integration into Spring-based applications and also transparently integrable with Spring Security.
    适合集成到 Spring项目中,也可以完美地与 Spring Security集成。
  • Integrated capabilities for encrypting the configuration of applications (i.e. datasources).
    用于加密应用程序(即数据源)配置的集成功能。
  • Specific features for high-performance encryption in multi-processor/multi-core systems.
    多处理器/多核系统中高性能加密的特定功能。
  • Open API for use with any JCE provider.
    开放 API 以与任何 JCE 提供程序一起使用。
  • …and much more
    …等等

二、Spring集成

1、 Maven依赖

<dependency><groupId>org.jasypt</groupId><artifactId>jasypt-spring31</artifactId><version>1.9.3</version>
</dependency>
<dependency><groupId>org.jasypt</groupId><artifactId>jasypt</artifactId><version>1.9.3</version>
</dependency>

2、application.xml的配置

<bean id="environmentVariablesConfiguration"class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"><!--加密方法--><property name="algorithm" value="PBEWithMD5AndDES" /><!--密码--><property name="password" value="mysqlPwd" /><!-- 如果想获得系统环境变量 --><!-- <property name="password" value="#{systemEnvironment['ENV_VARIABLE_NAME']}"/> -->
</bean>
<!-- 配置加密器,将用于解密 -->
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"><property name="config" ref="environmentVariablesConfiguration" />
</bean>
<!--jasypt扫描配置文件,对配置文件里加密数据进行解密-->
<bean id="propertyConfigurer" class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer"><constructor-arg ref="configurationEncryptor" /><property name="locations"><list><value>classpath:myconfig.properties</value><value>classpath:application.properties</value></list></property>
</bean>
<!--给bean的属性解密并赋值-->
<bean id="myBean" class="com.example.MyBean"><property name="pwd" value="${datasource.username}"/><property name="user" value="${datasource.password}"/>
</bean>

3、配置文件使用

使用 ENC(密文)

datasource.driver_class=com.mysql.jdbc.Driver
datasource.url=jdbc:mysql://localhost:3306/mydatabase
datasource.username=ENC(aXZJTKwF6Vt147qUJOrMuT3NDV4y0NzG)
datasource.password=ENC(LWzlg7fvAhO8RMIDDxifEORimjA91ibn)

4、方法加密

BasicTextEncryptor encryptor = new BasicTextEncryptor();
encryptor.setPassword("myPassword");
String encrypted = encryptor.encrypt("敏感信息");//密码加密
System.out.println(encrypted);

二、SpringBoot集成

1、 Maven依赖

<!-- https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.5</version>
</dependency>

2、 Java Bean配置jasyptStringEncryptor

@Bean("jasyptStringEncryptor")
public StringEncryptor stringEncryptor() {PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();config.setPassword("mypassword");config.setAlgorithm("PBEWITHHMACSHA512ANDAES_256");config.setKeyObtentionIterations("1000");config.setPoolSize("1");config.setProviderName("SunJCE");config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");config.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");config.setStringOutputType("base64");encryptor.setConfig(config);return encryptor;
}

3、配置文件使用

使用 ENC(密文)

datasource.driver_class=com.mysql.jdbc.Driver
datasource.url=jdbc:mysql://localhost:3306/mydatabase
datasource.username=ENC(aXZJTKwF6Vt147qUJOrMuT3NDV4y0NzG)
datasource.password=ENC(LWzlg7fvAhO8RMIDDxifEORimjA91ibn)

4、Bean使用加密字段自动解密

直接用@Value(“${配置文件的Key}”)

@RestController
@RequestMapping("/test")
public class TestController {@Value("${username}")private String username;@Value("${password}")private String password;
}

参考:https://blog.csdn.net/weixin_42962634/article/details/122455123

http://www.yayakq.cn/news/731544/

相关文章:

  • 寿县有做网站开发的吗河南郑州做网站汉狮
  • 做烘培的网站进销存软件终身免费版
  • 嘉兴网站制作价格wordpress新建页面没有内容
  • 天津市城乡建设网站专业做企业活动的趴网站
  • 下模板做网站wordpress wdpx
  • 网站设计流程是什么自助式网站制作
  • 网站建设费用应按几年摊销厦门市建设局网站住房保障专栏
  • 制作网站是什么专业北京企业聚集
  • 济宁网站建设top网站开发生命周期模型
  • 如何免费做公司网站网站建设效果好不好
  • 中跃建设集团网站在线代理服务器免费
  • 做外贸那个网站比较好网页设计实训总结1500字通用
  • 做网站维护的是什么人商丘做网站哪个好
  • 网站设计怎么做链接成都网站建设好的公司
  • 秦皇岛建设网站公司哪家好微信第三方做网站需要费用吗
  • 网站开发分销系统网站免费建站 图标
  • 怎么选择一家好的网站建设公司做设计需要知道的几个网站吗
  • 广饶网站建设中国建设报社网站
  • 中英文外贸网站模版沈阳男科医院哪家好点儿
  • 有没有做ppt很厉害的网站网页设计与制作实验报告总结
  • 东莞广告公司东莞网站建设价格网站 留言 以邮件形式
  • 网站源码下载后怎么用建一个网站大约需要花费多少钱
  • 山东住房与城乡建设网站怎么做网站策划的模板
  • 宝安做棋牌网站建设有哪些公司wordpress中文安装教程视频教程
  • 购物网站案例学习网站建设难吗
  • 织梦网站搬迁中学教材数字化学习资源的建设——教材配套网站的设计及发展趋势
  • 网站 邮件系统建设招标网络布线
  • 东莞建设网站推广公司地址广东网站建设哪家
  • 网站的优缺点宁波seo站外优化推广
  • 做设计网站的工作怎样在网上推广自己的产品