parent
314a112bae
commit
ec58bf197f
@ -0,0 +1,28 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
|
||||
/**
|
||||
* aes加密工具
|
||||
*/
|
||||
public class AesCryptoUtils {
|
||||
|
||||
public static String encrypt(String key, String content){
|
||||
if (StringUtils.isBlank(key) || StringUtils.isBlank(content)){
|
||||
throw new RuntimeException("错误");
|
||||
}
|
||||
AES aes = SecureUtil.aes(key.getBytes());
|
||||
byte[] encrypt = aes.encrypt(content);
|
||||
return aes.encryptHex(content);
|
||||
}
|
||||
|
||||
public static String decrypt(String key, String content){
|
||||
if (StringUtils.isBlank(key) || StringUtils.isBlank(content)){
|
||||
throw new RuntimeException("错误");
|
||||
}
|
||||
AES aes = SecureUtil.aes(key.getBytes());
|
||||
return aes.decryptStr(content, CharsetUtil.CHARSET_UTF_8);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
/**
|
||||
* 手机号工具类
|
||||
*/
|
||||
public class PhoneUtils {
|
||||
|
||||
public static String hidePhone(String phone){
|
||||
if (StringUtils.isEmpty(phone) || phone.length() < 11){
|
||||
throw new RuntimeException("手机号格式错误");
|
||||
}
|
||||
return phone.substring(0, 3) + "****" + phone.substring(7, 11);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue