46 lines
1.4 KiB
Java
46 lines
1.4 KiB
Java
|
|
package com.rzyc.config;
|
||
|
|
|
||
|
|
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
|
||
|
|
import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;
|
||
|
|
|
||
|
|
import javax.validation.constraints.NotNull;
|
||
|
|
|
||
|
|
public class Test {
|
||
|
|
|
||
|
|
@NotNull
|
||
|
|
private String a;
|
||
|
|
|
||
|
|
|
||
|
|
public static void main(String[] args) {
|
||
|
|
|
||
|
|
StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
|
||
|
|
EnvironmentPBEConfig config = new EnvironmentPBEConfig();
|
||
|
|
//加密的算法,这个算法是默认的
|
||
|
|
config.setAlgorithm("PBEWithMD5AndDES");
|
||
|
|
//加密的密钥,随便自己填写,很重要千万不要告诉别人
|
||
|
|
config.setPassword("rzyc2022");
|
||
|
|
standardPBEStringEncryptor.setConfig(config);
|
||
|
|
//自己的密码
|
||
|
|
String plainText = "123456";
|
||
|
|
//加密后密码
|
||
|
|
String encryptedText = standardPBEStringEncryptor.encrypt(plainText);
|
||
|
|
System.out.println(encryptedText);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
/*StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
|
||
|
|
EnvironmentPBEConfig config = new EnvironmentPBEConfig();
|
||
|
|
config.setAlgorithm("PBEWithMD5AndDES");
|
||
|
|
config.setPassword("rzyc2022");
|
||
|
|
standardPBEStringEncryptor.setConfig(config);
|
||
|
|
//加密后的密码
|
||
|
|
String encryptedText = "25Wv0r0vtL1iQgWiIl+oag==";
|
||
|
|
String plainText = standardPBEStringEncryptor.decrypt(encryptedText);
|
||
|
|
System.out.println(plainText);*/
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
}
|