-
Notifications
You must be signed in to change notification settings - Fork 6k
/
JasyptTest.java
40 lines (31 loc) · 1.06 KB
/
JasyptTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cn.iocoder.springboot.lab45.apollodemo;
import org.jasypt.encryption.StringEncryptor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class JasyptTest {
@Autowired
private StringEncryptor encryptor;
@Test
public void encode() {
// 第一个加密
String applicationName = "demo-application";
System.out.println(encryptor.encrypt(applicationName));
// // 第二个加密
// applicationName = "demo-app";
// System.out.println(encryptor.encrypt(applicationName));
}
@Value("${spring.application.name}")
private String applicationName;
@Test
public void print() {
System.out.println(applicationName);
}
@Value("${jasypt.encryptor.password}")
private String password;
}