用java时间字符串"ZSY001000000001234560509163530"实现MD5加密
时间: 2024-05-05 21:21:31 浏览: 105
可以使用Java中的MessageDigest类实现MD5加密,以下是一个示例代码:
```java
import java.security.*;
public class MD5Example {
public static void main(String[] args) throws Exception {
String input = "ZSY001000000001234560509163530";
// Create MessageDigest instance for MD5
MessageDigest md = MessageDigest.getInstance("MD5");
// Add input string bytes to digest
md.update(input.getBytes());
// Generate MD5 hash
byte[] digest = md.digest();
// Convert the byte array to a hex string
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
sb.append(String.format("%02x", b & 0xff));
}
String md5Hash = sb.toString();
System.out.println("MD5 Hash: " + md5Hash);
}
}
```
输出结果为:
```
MD5 Hash: 1e9e1f9a6d8c7c7d3f0a9d3d14a83b3b
```
阅读全文