-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample.text
executable file
·41 lines (34 loc) · 1.16 KB
/
example.text
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
public String createMD5Hash (String token) {
String s = token;
MessageDigest m;
String returnstring = null;
try {
m = MessageDigest.getInstance("MD5");
//m.reset();
m.update(s.getBytes(),0,s.length());
returnstring = new BigInteger(1,m.digest()).toString(16);
System.out.println("MD5: "+ returnstring);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return returnstring;
}
--------------------------------
include java.security.*;
... etc
sessionid="12345";
byte[] defaultBytes = sessionid.getBytes();
try{
MessageDigest algorithm = MessageDigest.getInstance("MD5";
algorithm.reset();
algorithm.update(defaultBytes);
byte messageDigest[] = algorithm.digest();
StringBuffer hexString = new StringBuffer();
for (int i=0;i<messageDigest.length;i++) {
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
}
String foo = messageDigest.toString();
System.out.println("sessionid "+sessionid+" md5 version is "+hexString.toString());
sessionid=hexString+"";
}catch(NoSuchAlgorithmException nsae){
}