Skip to content

Commit b3f03ed

Browse files
hengboygitee-org
authored andcommitted
!7 增加MD5加密工具
Merge pull request !7 from xct/master
2 parents 899e5aa + 8a45378 commit b3f03ed

File tree

2 files changed

+35
-0
lines changed
  • api-boot-samples
    • api-boot-sample-http-converter/src/main/java/org/minbox/framework/api/boot/sample
    • api-boot-sample-mybatis-enhance/src/main/java/org/minbox/framework/api/boot/sample/mybatis/enhance/dsl

2 files changed

+35
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.minbox.framework.api.boot.sample;
2+
3+
import java.security.MessageDigest;
4+
5+
public class MD5Util {
6+
7+
public final static String MD5(String s) {
8+
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
9+
'A', 'B', 'C', 'D', 'E', 'F' };
10+
11+
try {
12+
byte[] btInput = s.getBytes();
13+
// 获得MD5摘要算法的 MessageDigest 对象
14+
MessageDigest mdInst = MessageDigest.getInstance("MD5");
15+
// 使用指定的字节更新摘要
16+
mdInst.update(btInput);
17+
// 获得密文
18+
byte[] md = mdInst.digest();
19+
// 把密文转换成十六进制的字符串形式
20+
int j = md.length;
21+
char str[] = new char[j * 2];
22+
int k = 0;
23+
for (int i = 0; i < j; i++) {
24+
byte byte0 = md[i];
25+
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
26+
str[k++] = hexDigits[byte0 & 0xf];
27+
}
28+
return new String(str);
29+
} catch (Exception e) {
30+
e.printStackTrace();
31+
return null;
32+
}
33+
}
34+
}

api-boot-samples/api-boot-sample-mybatis-enhance/src/main/java/org/minbox/framework/api/boot/sample/mybatis/enhance/dsl/DSystemUser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static DSystemUser DSL() {
3636
return new DSystemUser("iot_system_user");
3737
}
3838

39+
3940
/**
4041
* 主键
4142
*/

0 commit comments

Comments
 (0)