标签:class blog code java http ext
|
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 |
package
cn.sevennight.test;import java.security.MessageDigest;public class md5{ public
static String MD5(String text) { try
{ MessageDigest md = MessageDigest.getInstance("MD5"); md.update(text.getBytes()); byte
b[] = md.digest(); int
i; StringBuffer buf = new
StringBuffer(""); for
(int offset = 0; offset < b.length; offset++) { i = b[offset]; if
(i < 0) i += 256; if
(i < 16) buf.append("0"); buf.append(Integer.toHexString(i)); } return
new String(buf.toString()); } catch
(Exception e) { e.printStackTrace(); return
""; } } public
static void main(String[] args) { String md5 =MD5("123456"); System.out.println(md5); } } |


标签:class blog code java http ext
原文地址:http://www.cnblogs.com/7night/p/3782380.html