-
Notifications
You must be signed in to change notification settings - Fork 25
/
helper.go
109 lines (84 loc) · 2.24 KB
/
helper.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package rsa
// 私钥
func FromPrivateKey(key []byte) Rsa {
return defaultRSA.FromPrivateKey(key)
}
// 私钥带密码
func FromPrivateKeyWithPassword(key []byte, password string) Rsa {
return defaultRSA.FromPrivateKeyWithPassword(key, password)
}
// 公钥
func FromPublicKey(key []byte) Rsa {
return defaultRSA.FromPublicKey(key)
}
// ==========
// 生成密钥
// bits = 512 | 1024 | 2048 | 4096
func GenerateKey(bits int) Rsa {
return defaultRSA.GenerateKey(bits)
}
// 生成密钥
func GenerateMultiPrimeKey(nprimes int, bits int) Rsa {
return defaultRSA.GenerateMultiPrimeKey(nprimes, bits)
}
// ==========
// PKCS1 私钥
func FromPKCS1PrivateKey(key []byte) Rsa {
return defaultRSA.FromPKCS1PrivateKey(key)
}
// PKCS1 私钥带密码
func FromPKCS1PrivateKeyWithPassword(key []byte, password string) Rsa {
return defaultRSA.FromPKCS1PrivateKeyWithPassword(key, password)
}
// PKCS1 公钥
func FromPKCS1PublicKey(key []byte) Rsa {
return defaultRSA.FromPKCS1PublicKey(key)
}
// ==========
// PKCS8 私钥
func FromPKCS8PrivateKey(key []byte) Rsa {
return defaultRSA.FromPKCS8PrivateKey(key)
}
// PKCS8 私钥带密码
func FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa {
return defaultRSA.FromPKCS8PrivateKeyWithPassword(key, password)
}
// PKCS8 公钥
func FromPKCS8PublicKey(key []byte) Rsa {
return defaultRSA.FromPKCS8PublicKey(key)
}
// ==========
// XML 私钥
func FromXMLPrivateKey(key []byte) Rsa {
return defaultRSA.FromXMLPrivateKey(key)
}
// XML 公钥
func FromXMLPublicKey(key []byte) Rsa {
return defaultRSA.FromXMLPublicKey(key)
}
// ==========
// Pkcs12Cert
func FromPKCS12Cert(key []byte) Rsa {
return defaultRSA.FromPKCS12Cert(key)
}
// Pkcs12Cert 带密码
func FromPKCS12CertWithPassword(key []byte, password string) Rsa {
return defaultRSA.FromPKCS12CertWithPassword(key, password)
}
// ==========
// 字节
func FromBytes(data []byte) Rsa {
return defaultRSA.FromBytes(data)
}
// 字符
func FromString(data string) Rsa {
return defaultRSA.FromString(data)
}
// Base64
func FromBase64String(data string) Rsa {
return defaultRSA.FromBase64String(data)
}
// Hex
func FromHexString(data string) Rsa {
return defaultRSA.FromHexString(data)
}