-
Notifications
You must be signed in to change notification settings - Fork 21
/
interface.go
71 lines (57 loc) · 1.14 KB
/
interface.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package crypto
import (
"crypto/cipher"
"github.com/deatil/go-cryptobin/tool"
)
// 配置接口
// config interface
type IOption interface {
// 密钥
// get Key
Key() []byte
// 向量
// get Iv
Iv() []byte
// 加密类型
// get Multiple
Multiple() Multiple
// 加密模式
// get Mode
Mode() Mode
// 填充模式
// get Padding
Padding() Padding
// 额外配置
// get extra Config
Config() *tool.Config
}
// 加密接口
// Encrypt interface
type IEncrypt interface {
// 加密
// Encrypt
Encrypt([]byte, IOption) ([]byte, error)
// 解密
// Decrypt
Decrypt([]byte, IOption) ([]byte, error)
}
// 模式接口
// Mode interface
type IMode interface {
// 加密
// Encrypt
Encrypt([]byte, cipher.Block, IOption) ([]byte, error)
// 解密
// Decrypt
Decrypt([]byte, cipher.Block, IOption) ([]byte, error)
}
// 填充接口
// Padding interface
type IPadding interface {
// 补码
// Padding
Padding([]byte, int, IOption) []byte
// 解密
// UnPadding
UnPadding([]byte, IOption) ([]byte, error)
}