File tree 2 files changed +63
-0
lines changed
2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
* [ mysql临时关闭安全更新] ( ./docs/mysql/mysql_common_use.md )
19
19
20
+ ## 加密解密
21
+
22
+ * [ go语言和java语言加密解密对比] ( ./docs/encrypt/go-java-encrypt.md )
23
+
20
24
21
25
## 好用的在线工具
22
26
Original file line number Diff line number Diff line change
1
+ # go语言和java语言加密解密对比
2
+
3
+ ## Golang两种方法实现MD5加密
4
+
5
+ ```
6
+ package main
7
+
8
+ import (
9
+ "crypto/md5"
10
+ "fmt"
11
+ "io"
12
+ )
13
+
14
+ func main() {
15
+ str := "123456"
16
+ //方法一
17
+ data := []byte(str)
18
+ has := md5.Sum(data)
19
+ md5str1 := fmt.Sprintf("%x", has) //将[]byte转成16进制
20
+ fmt.Println(md5str1)
21
+ //方法二
22
+ w := md5.New()
23
+ io.WriteString(w, str)
24
+ //将str写入到w中
25
+ md5str2 := fmt.Sprintf("%x", w.Sum(nil))
26
+
27
+ fmt.Println(md5str2)
28
+
29
+
30
+
31
+
32
+
33
+ //结果
34
+ //e10adc3949ba59abbe56e057f20f883e
35
+ //e10adc3949ba59abbe56e057f20f883e
36
+ }
37
+ ```
38
+
39
+ ## java实现MD5加密
40
+
41
+ ```
42
+ /*
43
+ * Copyright (c) 2021. 武汉美宸时科科技有限公司 www.fashiontech.top
44
+ */
45
+
46
+ package top.fashiontech.device.biz;
47
+
48
+ import org.apache.commons.codec.digest.DigestUtils;
49
+
50
+ public class OperationApplication {
51
+ public static void main(String[] args) {
52
+ System.out.println("-----------------ooooo-------" + DigestUtils.md5Hex("123456"));
53
+ }
54
+ }
55
+
56
+ //结果
57
+ //e10adc3949ba59abbe56e057f20f883e
58
+ //e10adc3949ba59abbe56e057f20f883e
59
+ ```
You can’t perform that action at this time.
0 commit comments