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

淮安做网站的有多少贵州灵溪seo整站优化

淮安做网站的有多少,贵州灵溪seo整站优化,嘉定网站设计公司,云南网站建设首选才力文章目录 一、介绍二、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/633190/

相关文章:

  • 做互联网的网站长沙网站关键词seo
  • 网站域名使用期花钱制作网站有什么好处
  • 做网站用的腾讯云服务器前端开发师
  • 济南历山北路网站建设卖护肤在哪个网站做宣传好
  • 网站运营管理龙岩58同城
  • 哈尔滨门户网站制作哪家好软件开发文档清单
  • 网站建设哪里好点永久免费自助建站系统
  • 网站建设 数据分析网站建设思路方法
  • 淘宝客网站建设儿童教育自适应网站模板
  • 加强网站微信信息编辑队伍建设专门做库存的网站
  • 沈阳建站模板展示网络营销技巧和营销方法
  • 网站开发的完整流程图wordpress3万篇文章优化
  • 云阳网站制作网站建设工作计划表
  • 深圳建设外贸网站wordpress文章提交
  • 上海高端网站制作哈尔滨响应式网站建设公司
  • 巩义郑州网站建设创意网名女
  • 网站快速收录平台青岛网站排名公司
  • 无锡公司网站建设电话高性价比网站建设
  • 门户网站建设的重要性服务器主机搭建网站
  • 上海网站设计找哪家陕西省建设监理协会证书查询网站
  • 张家港市规划建设网站wordpress优酷视频插件下载
  • 哪些网站是动态的网页设计公司有什么部门
  • 网站如何做监测链接三分钟做网站
  • 包头网站开发公司做棋牌游戏网站
  • 建网站的公司哪个好uniapp怎么做淘客网站
  • 铆钉机 东莞网站建设公司网站域名实名认证怎么做
  • shopify网站建设wordpress自动原创
  • 专业建设外贸网站制作微信h5用什么软件制作
  • 潍坊网站制作套餐我的长沙app是哪里开发的
  • 竞价网站建设大朗做网站在