Utils.java
1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.shunzhi.parent.util;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import com.shunzhi.parent.R;
public class Utils {
private Utils() {}
public static String MD5(String str) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(str.getBytes("utf-8"));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1, 3));
}
return sb.toString().toUpperCase();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static String md5(String str) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
byte[] array = md.digest(str.getBytes("utf-8"));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i] & 0xff) | 0x100).substring(1, 3));
}
return sb.toString().toUpperCase();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
public static AlertDialog.Builder styleDialogBuilder(Context context) {
return new AlertDialog.Builder(context, R.style.AlertDialogCustom);
}
}