mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 17:38:48 +08:00
Pre Merge pull request !735 from 这夏天依然平凡/dev
This commit is contained in:
commit
ac017b5184
@ -37,6 +37,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串
|
* @return 加密后字符串
|
||||||
*/
|
*/
|
||||||
public static String encryptByBase64(String data) {
|
public static String encryptByBase64(String data) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
return Base64.encode(data, StandardCharsets.UTF_8);
|
return Base64.encode(data, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +50,9 @@ public class EncryptUtils {
|
|||||||
* @return 解密后字符串
|
* @return 解密后字符串
|
||||||
*/
|
*/
|
||||||
public static String decryptByBase64(String data) {
|
public static String decryptByBase64(String data) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
return Base64.decodeStr(data, StandardCharsets.UTF_8);
|
return Base64.decodeStr(data, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +64,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Base64编码
|
* @return 加密后字符串, 采用Base64编码
|
||||||
*/
|
*/
|
||||||
public static String encryptByAes(String data, String password) {
|
public static String encryptByAes(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -77,6 +86,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptByAesHex(String data, String password) {
|
public static String encryptByAesHex(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -96,6 +108,9 @@ public class EncryptUtils {
|
|||||||
* @return 解密后字符串
|
* @return 解密后字符串
|
||||||
*/
|
*/
|
||||||
public static String decryptByAes(String data, String password) {
|
public static String decryptByAes(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
throw new IllegalArgumentException("AES需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -115,6 +130,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Base64编码
|
* @return 加密后字符串, 采用Base64编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySm4(String data, String password) {
|
public static String encryptBySm4(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -134,6 +152,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySm4Hex(String data, String password) {
|
public static String encryptBySm4Hex(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -153,6 +174,9 @@ public class EncryptUtils {
|
|||||||
* @return 解密后字符串
|
* @return 解密后字符串
|
||||||
*/
|
*/
|
||||||
public static String decryptBySm4(String data, String password) {
|
public static String decryptBySm4(String data, String password) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(password)) {
|
if (StrUtil.isBlank(password)) {
|
||||||
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
throw new IllegalArgumentException("SM4需要传入秘钥信息");
|
||||||
}
|
}
|
||||||
@ -185,6 +209,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Base64编码
|
* @return 加密后字符串, 采用Base64编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySm2(String data, String publicKey) {
|
public static String encryptBySm2(String data, String publicKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(publicKey)) {
|
if (StrUtil.isBlank(publicKey)) {
|
||||||
throw new IllegalArgumentException("SM2需要传入公钥进行加密");
|
throw new IllegalArgumentException("SM2需要传入公钥进行加密");
|
||||||
}
|
}
|
||||||
@ -200,6 +227,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySm2Hex(String data, String publicKey) {
|
public static String encryptBySm2Hex(String data, String publicKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(publicKey)) {
|
if (StrUtil.isBlank(publicKey)) {
|
||||||
throw new IllegalArgumentException("SM2需要传入公钥进行加密");
|
throw new IllegalArgumentException("SM2需要传入公钥进行加密");
|
||||||
}
|
}
|
||||||
@ -215,6 +245,9 @@ public class EncryptUtils {
|
|||||||
* @return 解密后字符串
|
* @return 解密后字符串
|
||||||
*/
|
*/
|
||||||
public static String decryptBySm2(String data, String privateKey) {
|
public static String decryptBySm2(String data, String privateKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(privateKey)) {
|
if (StrUtil.isBlank(privateKey)) {
|
||||||
throw new IllegalArgumentException("SM2需要传入私钥进行解密");
|
throw new IllegalArgumentException("SM2需要传入私钥进行解密");
|
||||||
}
|
}
|
||||||
@ -243,6 +276,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Base64编码
|
* @return 加密后字符串, 采用Base64编码
|
||||||
*/
|
*/
|
||||||
public static String encryptByRsa(String data, String publicKey) {
|
public static String encryptByRsa(String data, String publicKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(publicKey)) {
|
if (StrUtil.isBlank(publicKey)) {
|
||||||
throw new IllegalArgumentException("RSA需要传入公钥进行加密");
|
throw new IllegalArgumentException("RSA需要传入公钥进行加密");
|
||||||
}
|
}
|
||||||
@ -258,6 +294,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptByRsaHex(String data, String publicKey) {
|
public static String encryptByRsaHex(String data, String publicKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(publicKey)) {
|
if (StrUtil.isBlank(publicKey)) {
|
||||||
throw new IllegalArgumentException("RSA需要传入公钥进行加密");
|
throw new IllegalArgumentException("RSA需要传入公钥进行加密");
|
||||||
}
|
}
|
||||||
@ -273,6 +312,9 @@ public class EncryptUtils {
|
|||||||
* @return 解密后字符串
|
* @return 解密后字符串
|
||||||
*/
|
*/
|
||||||
public static String decryptByRsa(String data, String privateKey) {
|
public static String decryptByRsa(String data, String privateKey) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
if (StrUtil.isBlank(privateKey)) {
|
if (StrUtil.isBlank(privateKey)) {
|
||||||
throw new IllegalArgumentException("RSA需要传入私钥进行解密");
|
throw new IllegalArgumentException("RSA需要传入私钥进行解密");
|
||||||
}
|
}
|
||||||
@ -287,6 +329,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptByMd5(String data) {
|
public static String encryptByMd5(String data) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
return SecureUtil.md5(data);
|
return SecureUtil.md5(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,6 +342,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySha256(String data) {
|
public static String encryptBySha256(String data) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
return SecureUtil.sha256(data);
|
return SecureUtil.sha256(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,6 +355,9 @@ public class EncryptUtils {
|
|||||||
* @return 加密后字符串, 采用Hex编码
|
* @return 加密后字符串, 采用Hex编码
|
||||||
*/
|
*/
|
||||||
public static String encryptBySm3(String data) {
|
public static String encryptBySm3(String data) {
|
||||||
|
if (StrUtil.isBlank(data)) {
|
||||||
|
return StrUtil.EMPTY;
|
||||||
|
}
|
||||||
return SmUtil.sm3(data);
|
return SmUtil.sm3(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user