forked from forgoer/openssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aes.go
executable file
·44 lines (36 loc) · 869 Bytes
/
aes.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
43
44
package openssl
import (
"crypto/aes"
)
// AesECBEncrypt
func AesECBEncrypt(src, key []byte, padding string) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return ECBEncrypt(block, src, padding)
}
// AesECBDecrypt
func AesECBDecrypt(src, key []byte, padding string) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return ECBDecrypt(block, src, padding)
}
// AesCBCEncrypt
func AesCBCEncrypt(src, key, iv []byte, padding string) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return CBCEncrypt(block, src, iv, padding)
}
// AesCBCDecrypt
func AesCBCDecrypt(src, key, iv []byte, padding string) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return CBCDecrypt(block, src, iv, padding)
}