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
|
//主要实现过程,其中paramString2为手机串号,paramLong为uin
this
.cSb = getMessageDigest((paramString2 + paramLong).getBytes()).substring(
0
,
7
);
String str =
"PRAGMA key=\""
+
this
.cSb +
"\";"
;
//
package
com.gracecode.android.signature.wechat;
import
java.security.MessageDigest;
public
final
class
MD5
{
public
static
final
String getMessageDigest(
byte
[] paramArrayOfByte)
{
char
[] arrayOfChar1 = {
48
,
49
,
50
,
51
,
52
,
53
,
54
,
55
,
56
,
57
,
97
,
98
,
99
,
100
,
101
,
102
};
try
{
MessageDigest localMessageDigest = MessageDigest.getInstance(
"MD5"
);
localMessageDigest.update(paramArrayOfByte);
byte
[] arrayOfByte = localMessageDigest.digest();
int
i = arrayOfByte.length;
char
[] arrayOfChar2 =
new
char
[i *
2
];
int
j =
0
;
int
k =
0
;
while
(
true
)
{
if
(j >= i)
return
new
String(arrayOfChar2);
int
m = arrayOfByte[j];
int
n = k +
1
;
arrayOfChar2[k] = arrayOfChar1[(
0xF
& m >>>
4
)];
k = n +
1
;
arrayOfChar2[n] = arrayOfChar1[(m &
0xF
)];
j++;
}
}
catch
(Exception localException)
{
}
return
null
;
}
|
本文转自 张宇 51CTO博客,原文链接:http://blog.51cto.com/zhangyu/1415004,如需转载请自行联系原作者