File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Utils for golang
8
8
9
9
+ redisutil
10
10
+ dbutil
11
+ + cryptoutil
11
12
12
13
#### v0.2.0
13
14
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ import (
4
4
"bytes"
5
5
"crypto/aes"
6
6
"crypto/cipher"
7
+ "crypto/md5"
8
+ "crypto/sha1"
7
9
"encoding/base64"
10
+ "fmt"
8
11
"github.com/jumpingcoder/quickutil4go/utils/logutil"
9
12
"strings"
10
13
)
@@ -21,6 +24,16 @@ func Base64Decrypt(content string) []byte {
21
24
return output
22
25
}
23
26
27
+ func MD5Encrypt (content []byte ) string {
28
+ sum := md5 .Sum (content )
29
+ return fmt .Sprintf ("%x" , sum )
30
+ }
31
+
32
+ func SHA1Encrypt (content []byte ) string {
33
+ sum := sha1 .Sum (content )
34
+ return fmt .Sprintf ("%x" , sum )
35
+ }
36
+
24
37
func AESCBCEncrypt (content []byte , key []byte , iv []byte ) []byte {
25
38
block , err := aes .NewCipher (key )
26
39
if err != nil {
Original file line number Diff line number Diff line change @@ -11,3 +11,7 @@ func TestEncryptConfigHandler(t *testing.T) {
11
11
func TestDecryptConfigHandler (t * testing.T ) {
12
12
t .Log (DecryptConfigHandler ("ENC(ozPh7o7XOvEup69IjSAbOg==)" , "0000000011111111" ))
13
13
}
14
+
15
+ func TestMD5Encrypt (t * testing.T ) {
16
+ t .Log (MD5Encrypt ([]byte ("123456" )))
17
+ }
You can’t perform that action at this time.
0 commit comments