提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.common.utils; |
H |
2 |
|
|
3 |
import java.io.UnsupportedEncodingException; |
|
4 |
import java.math.BigInteger; |
|
5 |
import java.security.MessageDigest; |
|
6 |
import java.security.NoSuchAlgorithmException; |
|
7 |
|
|
8 |
/** |
|
9 |
* @author PanZhibao |
|
10 |
* @Description |
|
11 |
* @createTime 2024年06月05日 |
|
12 |
*/ |
|
13 |
public class MD5Util { |
|
14 |
|
|
15 |
public static String getMD5Str(String str) { |
|
16 |
byte[] digest = null; |
|
17 |
try { |
|
18 |
MessageDigest md5 = MessageDigest.getInstance("md5"); |
|
19 |
digest = md5.digest(str.getBytes("utf-8")); |
|
20 |
} catch (NoSuchAlgorithmException e) { |
|
21 |
e.printStackTrace(); |
|
22 |
} catch (UnsupportedEncodingException e) { |
|
23 |
e.printStackTrace(); |
|
24 |
} |
|
25 |
//16是表示转换为16进制数 |
|
26 |
String md5Str = new BigInteger(1, digest).toString(16); |
|
27 |
return md5Str; |
|
28 |
} |
|
29 |
} |