8 changed files with 208 additions and 28 deletions
@ -0,0 +1,75 @@ |
|||
package com.zdxt.enforcementcode.common.config; |
|||
|
|||
import org.dromara.common.core.utils.SpringUtils; |
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 深i企相关配置 |
|||
* |
|||
* @author ruoyi |
|||
*/ |
|||
@Component |
|||
@ConfigurationProperties(prefix = "siq") |
|||
public class SiqConfig |
|||
{ |
|||
/** 深i企对接URL */ |
|||
private String siqUrl; |
|||
|
|||
/** 深i企对接code */ |
|||
private String code; |
|||
|
|||
/** 深i企对接密钥 */ |
|||
private String secretKey; |
|||
|
|||
/** 模拟数据开关 */ |
|||
private MockConfig mock = new MockConfig(); |
|||
|
|||
/** |
|||
* 模拟配置内部类 |
|||
*/ |
|||
public static class MockConfig { |
|||
/** 是否启用模拟数据 */ |
|||
private boolean enabled; |
|||
|
|||
public boolean isEnabled() { |
|||
return enabled; |
|||
} |
|||
|
|||
public void setEnabled(boolean enabled) { |
|||
this.enabled = enabled; |
|||
} |
|||
} |
|||
|
|||
public String getSiqUrl() { |
|||
return siqUrl; |
|||
} |
|||
|
|||
public void setSiqUrl(String siqUrl) { |
|||
this.siqUrl = siqUrl; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getSecretKey() { |
|||
return secretKey; |
|||
} |
|||
|
|||
public void setSecretKey(String secretKey) { |
|||
this.secretKey = secretKey; |
|||
} |
|||
|
|||
public MockConfig getMock() { |
|||
return mock; |
|||
} |
|||
|
|||
public void setMock(MockConfig mock) { |
|||
this.mock = mock; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
package com.zdxt.enforcementcode.common.util.jasypt; |
|||
|
|||
|
|||
|
|||
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor; |
|||
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig; |
|||
|
|||
|
|||
/** |
|||
* alibaba druid加解密规则: |
|||
* 明文密码+私钥(privateKey)加密=加密密码 |
|||
* 加密密码+公钥(publicKey)解密=明文密码 |
|||
*/ |
|||
public final class JasyptUtils { |
|||
/** |
|||
* 加密算法 |
|||
*/ |
|||
private static final String PBEWITHMD5ANDDES = "PBEWithMD5AndDES"; |
|||
/** |
|||
* @param text 待加密原文 |
|||
* @param crack 盐值(密钥) |
|||
* @return 加密后的字符串 |
|||
* @Description: Jasypt加密(PBEWithMD5AndDES) |
|||
*/ |
|||
public static String encryptWithMD5(String text, String crack) { |
|||
//1.创建加解密工具实例
|
|||
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); |
|||
//2.加解密配置
|
|||
EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); |
|||
config.setAlgorithm(PBEWITHMD5ANDDES); |
|||
config.setPassword(crack); |
|||
encryptor.setConfig(config); |
|||
//3.加密
|
|||
return encryptor.encrypt(text); |
|||
} |
|||
|
|||
/** |
|||
* @param text 待解密原文 |
|||
* @param crack 盐值(密钥) |
|||
* @return 解密后的字符串 |
|||
* @Description: Jasypt解密(PBEWithMD5AndDES) |
|||
*/ |
|||
public static String decryptWithMD5(String text, String crack) { |
|||
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); |
|||
EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig(); |
|||
config.setAlgorithm(PBEWITHMD5ANDDES); |
|||
config.setPassword(crack); |
|||
encryptor.setConfig(config); |
|||
return encryptor.decrypt(text); |
|||
} |
|||
public static void main(String[] args) { |
|||
//加密
|
|||
String s = encryptWithMD5("szsf@zfjd", "ATPfOhpnAVp6yBas7RU"); |
|||
System.out.println(s); |
|||
String channelcs1 = decryptWithMD5("zTr/tj2VgFxQyunI4eIL7NyRWDPSMPSB0VlwTYeHTdsEWyu1H96xWw==", "ATPfOhpnAVp6yBas7RU"); |
|||
System.out.println(channelcs1); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue