main方法

public static void main(String[] args) {

BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//加密所需的salt(盐)
textEncryptor.setPassword("Yc@0!9IsC");
//要加密的数据(数据库的用户名或密码)
String s1 = textEncryptor.encrypt("ftp21");
String s2 = textEncryptor.encrypt("Summer2018");
String s3 = textEncryptor.encrypt("Anfang@123!");
// String s4 = textEncryptor.encrypt("admin123");
String s5 = textEncryptor.encrypt("cegs");
String s6 = textEncryptor.encrypt("ivms_thr");
String s7 = textEncryptor.encrypt("Anfang@123!");
String s8 = textEncryptor.encrypt("123456");
String s9 = textEncryptor.encrypt("ftp21");

System.out.println("s1: "+s1);
System.out.println("s2: "+s2);
System.out.println("s3: "+s3);
// System.out.println("ftp.privateUser: "+s4);
System.out.println("ftp.privatePwd: "+s5);
System.out.println("ftp.intranetUser: "+s6);
System.out.println("Anfang@123!:" + s7);
System.out.println("123456:" + s8);
System.out.println("ftp21:" + s9);

}

依赖

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

启动类 + 注解

@SpringBootApplication
@EnableEncryptableProperties  //加密注解
//@PropertySource(name="EncryptedProperties", value = "classpath:/application.properties")
public class Application
{
public static void main( String[] args )
{
/*BCryptPasswordEncoder en = new BCryptPasswordEncoder();
String pw = en.encode("12345611111");*/
SpringApplication sa = new SpringApplication(Application.class);
sa.setBannerMode(Banner.Mode.OFF);
sa.run(args);
}
}

java application.properties 密码加密的更多相关文章

  1. 如果你的application.properties中还存在明文密码----加密Spring Boot中的application.properties

    1 概述 什么?都2020年了还在Spring Boot的配置文件中写明文密码? 虽然是小项目,明文也没人看. 明文简单快捷方便啊!!! 你看直接用户名root密码123456多么简单!!! ... ...

  2. application.properties多环境配置文件、jar包外部配置文件、配置项加密、程序中配置使用

    一.简介 spring boot项目application.properties文件存放及使用介绍 二.方法一多环境配置文件 我们一般都会有多个应用环境,开发环境.测试环境.生产环境,各个环境的配置会 ...

  3. 使用哈希加盐法来为密码加密(补充JAVA的实现)

    使用哈希加盐法来为密码加密 转自:http://www.cnblogs.com/jfzhu/p/4023439.html 转载请注明出处   (一)为什么要用哈希函数来加密密码 如果你需要保存密码(比 ...

  4. java工具类学习,系统中用户密码加密总结

    现在项目,用户注册登录部分很少有涉及到了,原因:现在热门开发框架都已经在底层帮我们做了一套用户注册,密码加密,登录认证,权限控制,缓存数据等基本功能. 这有利于项目的快速完成,只需要搬砖码畜们专注于业 ...

  5. Java 读取application.properties配置文件中配置

    实际开发中若需要读取配置文件application.properties中的配置,代码如下.例:读取配置文件中name属性配置值: 代码如下: import org.springframework.c ...

  6. 基于RSA的前后端登陆密码加密JAVA实现(转)

    RSA加密算法简介 SA加密算法是一种非对称加密算法.在公开密钥加密和电子商业中RSA被广泛使用.对极大整数做因数分解的难度决定了RSA算法的可靠性.换言之,对一极大整数做因数分解愈困难,RSA算法愈 ...

  7. Java 第十一届 蓝桥杯 省模拟赛 凯撒密码加密

    凯撒密码加密 题目 问题描述 给定一个单词,请使用凯撒密码将这个单词加密. 凯撒密码是一种替换加密的技术,单词中的所有字母都在字母表上向后偏移3位后被替换成密文.即a变为d,b变为e,-,w变为z,x ...

  8. Spring Boot (四): Druid 连接池密码加密与监控

    在上一篇文章<Spring Boot (三): ORM 框架 JPA 与连接池 Hikari> 我们介绍了 JPA 与连接池 Hikari 的整合使用,在国内使用比较多的连接池还有一个是阿 ...

  9. Spring Boot 配置文件密码加密两种方案

    Spring Boot 配置文件密码加密两种方案 jasypt 加解密 jasypt 是一个简单易用的加解密Java库,可以快速集成到 Spring 项目中.可以快速集成到 Spring Boot 项 ...

随机推荐

  1. Python之hashlib模块的使用

    hashlib模块主要的作用: 加密保护消息安全,常用的加密算法如MD5,SHA1等. 1.查看可用的算法有哪些 #!/usr/bin/env python # -*- coding: utf-8 - ...

  2. python爬虫添加请求头

    request import requests headers = { # 'Accept': 'application/json, text/javascript, */*; q=0.01', # ...

  3. redis异步处理

    $reids = new Redis; $redis->connect('localhost',6379); $redis->auth(''); //将数组转换成字符串再存到redis中 ...

  4. poi 1017 Packets 贪心+模拟

    Packets Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 48349   Accepted: 16392 Descrip ...

  5. BZOJ 2651 城市改建 树形DP+模拟?

    题意 给一颗树,删除一条边再加一条边,使它仍为一颗树且任意两点间的距离的最大值最小. 题目数据范围描述有问题,n为1或重建不能使任意两点距离最大值变小,可以输出任意答案. 分析 删除一条边后会使它变成 ...

  6. js监听transition过渡事件

    html <div id="mydiv"> </div> style #mydiv{ width:100px; height:100px; backgrou ...

  7. ngx_http_auth_request自用

    server { listen 80; server_name www.php12.cn php12.mama1314.com; root /var/www/shf; location / { ind ...

  8. vim(vi)下的三种模式及其相关命令

    vim(vi)下的三种模式1.命令行模式 2.末行模式 3.插入模式 三种模式的联系及其相互转换 在我们输入vi命令进入编写程序的页面后,我们看到的是命令行模式,在我们输入“a”.“i”.“o”.“O ...

  9. python3.8 := and python3.7 dataclass

    代码示例 from dataclasses import field,dataclass @dataclass class People: name :str =field(init="张三 ...

  10. Python3并发写文件

    使用python2在进行并发写的时候,发现文件会乱掉,就是某一行中间会插入其他行的内容. 但是在使用python3进行并发写的时候,无论是多进程,还是多线程,都没有出现这个问题,难道是python3的 ...