forked from forgoer/openssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3des.go
executable file
·42 lines (34 loc) · 908 Bytes
/
3des.go
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
package openssl
import "crypto/des"
// Des3ECBEncrypt
func Des3ECBEncrypt(src, key []byte, padding string) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
return ECBEncrypt(block, src, padding)
}
// Des3ECBDecrypt
func Des3ECBDecrypt(src, key []byte, padding string) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
return ECBDecrypt(block, src, padding)
}
// Des3CBCEncrypt
func Des3CBCEncrypt(src, key, iv []byte, padding string) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
return CBCEncrypt(block, src, iv, padding)
}
// Des3CBCDecrypt
func Des3CBCDecrypt(src, key, iv []byte, padding string) ([]byte, error) {
block, err := des.NewTripleDESCipher(key)
if err != nil {
return nil, err
}
return CBCDecrypt(block, src, iv, padding)
}