From 59340c0b9107c813d6b3a5c953d693212485ad11 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 20 八月 2025 13:31:22 +0800
Subject: [PATCH] 2025年08月20日13:31:14
---
app/src/main/java/com/hdl/photovoltaic/utils/Md5Utils.java | 52 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/Md5Utils.java b/app/src/main/java/com/hdl/photovoltaic/utils/Md5Utils.java
index 34a1a39..a80b8ee 100644
--- a/app/src/main/java/com/hdl/photovoltaic/utils/Md5Utils.java
+++ b/app/src/main/java/com/hdl/photovoltaic/utils/Md5Utils.java
@@ -8,13 +8,15 @@
import java.security.NoSuchAlgorithmException;
public class Md5Utils {
+
+
/**
* MD5杞瓧绗︿覆
*/
- public static String encodeMD5(String s) {
+ public static String encodeMD5(byte[] f) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
- digest.update(s.getBytes(StandardCharsets.UTF_8));
+ digest.update(f);
byte[] messageDigest = digest.digest();
return toHexString(messageDigest);
} catch (NoSuchAlgorithmException e) {
@@ -22,6 +24,7 @@
}
return "";
}
+
private static String toHexString(byte[] keyData) {
if (keyData == null) {
@@ -37,6 +40,21 @@
sb.append(hexStr);
}
return sb.toString();
+ }
+
+ /**
+ * MD5杞瓧绗︿覆
+ */
+ public static String encodeMD5(String s) {
+ try {
+ MessageDigest digest = MessageDigest.getInstance("MD5");
+ digest.update(s.getBytes(StandardCharsets.UTF_8));
+ byte[] messageDigest = digest.digest();
+ return toHexString(messageDigest);
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ return "";
}
/**
@@ -89,21 +107,21 @@
return bigInt.toString(16);
}
- /**
- * MD5鏂囦欢杞瓧绗︿覆
- */
- public static String encodeMD5(byte[] f) {
- MessageDigest digest;
- try {
- digest = MessageDigest.getInstance("MD5");
- digest.update(f);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- BigInteger bigInt = new BigInteger(1, digest.digest());
- return bigInt.toString(16);
- }
+// /**
+// * MD5鏂囦欢杞瓧绗︿覆
+// */
+// public static String encodeMD5(byte[] f) {
+// MessageDigest digest;
+// try {
+// digest = MessageDigest.getInstance("MD5");
+// digest.update(f);
+// } catch (Exception e) {
+// e.printStackTrace();
+// return null;
+// }
+// BigInteger bigInt = new BigInteger(1, digest.digest());
+// return bigInt.toString(16);
+// }
}
--
Gitblit v1.8.0