Documentation ¶
Index ¶
- Constants
- func NewECBDecrypt(b cipher.Block) cipher.BlockMode
- type BaseStruct
- func (e BaseStruct) String() string
- func (e BaseStruct) ToBase32Bytes() []byte
- func (e BaseStruct) ToBase32String() string
- func (e BaseStruct) ToBase64Bytes() []byte
- func (e BaseStruct) ToBase64String() string
- func (e BaseStruct) ToBytes() []byte
- func (e BaseStruct) ToHexBytes() []byte
- func (e BaseStruct) ToHexString() string
- func (e BaseStruct) ToString() string
- type Cipher
- func (c *Cipher) PKCS5Padding(src []byte) []byte
- func (c *Cipher) PKCS5UnPadding(src []byte) []byte
- func (c *Cipher) PKCS7Padding(src []byte, size int) []byte
- func (c *Cipher) PKCS7UnPadding(src []byte) []byte
- func (c *Cipher) Padding(src []byte, blockSize int) []byte
- func (c *Cipher) RSAGeneratePrivateKey(bits int) *Cipher
- func (c *Cipher) RSAGeneratePublicKey(priKeyOption ...[]byte) *Cipher
- func (c *Cipher) SetIV(iv interface{}) *Cipher
- func (c *Cipher) SetKey(key interface{}) *Cipher
- func (c *Cipher) SetMode(mode ModeType) *Cipher
- func (c *Cipher) SetPadding(padding PaddingType) *Cipher
- func (c *Cipher) SetPrivateKey(key interface{}) *Cipher
- func (c *Cipher) SetPublicKey(key interface{}) *Cipher
- func (c *Cipher) UnPadding(src []byte) []byte
- func (c *Cipher) ZeroPadding(src []byte, size int) []byte
- func (c *Cipher) ZeroUnPadding(src []byte) []byte
- type Decrypt
- func (e Decrypt) ByAes(c *Cipher) Decrypt
- func (e Decrypt) ByDes(c *Cipher) Decrypt
- func (e Decrypt) ByRC4(c *Cipher) Decrypt
- func (e Decrypt) ByRSA(c *Cipher) Decrypt
- func (e Decrypt) ByTripleDes(c *Cipher) Decrypt
- func (e Decrypt) ByXor(key []byte) Decrypt
- func (e Decrypt) FromBase32Byte(b []byte) Decrypt
- func (e Decrypt) FromBase32String(s string) Decrypt
- func (e Decrypt) FromBase64Byte(b []byte) Decrypt
- func (e Decrypt) FromBase64String(s string) Decrypt
- func (e Decrypt) FromBytes(b []byte) Decrypt
- func (e Decrypt) FromFile(f interface{}) Decrypt
- func (e Decrypt) FromHexByte(b []byte) Decrypt
- func (e Decrypt) FromHexString(s string) Decrypt
- func (e Decrypt) FromString(s string) Decrypt
- type Encrypt
- func (e Encrypt) ByAes(c *Cipher) Encrypt
- func (e Encrypt) ByDes(c *Cipher) Encrypt
- func (e Encrypt) ByRC4(c *Cipher) Encrypt
- func (e Encrypt) ByRSA(c *Cipher) Encrypt
- func (e Encrypt) ByTripleDes(c *Cipher) Encrypt
- func (e Encrypt) ByXor(key []byte) Encrypt
- func (e Encrypt) FromBytes(b []byte) Encrypt
- func (e Encrypt) FromFile(f interface{}) Encrypt
- func (e Encrypt) FromString(s string) Encrypt
- type ModeType
- func (m *ModeType) CBC() ModeType
- func (m *ModeType) CFB() ModeType
- func (m *ModeType) CTR() ModeType
- func (m *ModeType) ECB() ModeType
- func (m *ModeType) OFB() ModeType
- func (m *ModeType) RsaOaepMD5() ModeType
- func (m *ModeType) RsaOaepSHA1() ModeType
- func (m *ModeType) RsaOaepSHA256() ModeType
- func (m *ModeType) RsaOaepSHA384() ModeType
- func (m *ModeType) RsaOaepSHA512() ModeType
- type PaddingType
Constants ¶
const (
MaxFileBlock = 1 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseStruct ¶
type BaseStruct struct { Err error // contains filtered or unexported fields }
func (BaseStruct) String ¶
func (e BaseStruct) String() string
String implements the interface Stringer for encode struct. 实现 Stringer 接口
func (BaseStruct) ToBase32Bytes ¶
func (e BaseStruct) ToBase32Bytes() []byte
ToBase32Bytes outputs as byte slice with base32 encoding. 输出经过 base32 编码的字节切片
func (BaseStruct) ToBase32String ¶
func (e BaseStruct) ToBase32String() string
ToBase32String outputs as string with base32 encoding. 输出经过 base32 编码的字符串
func (BaseStruct) ToBase64Bytes ¶
func (e BaseStruct) ToBase64Bytes() []byte
ToBase64Bytes outputs as byte slice with base64 encoding. 输出经过 base64 编码的字节切片
func (BaseStruct) ToBase64String ¶
func (e BaseStruct) ToBase64String() string
ToBase64String outputs as string with base64 encoding. 输出经过 base64 编码的字符串
func (BaseStruct) ToBytes ¶
func (e BaseStruct) ToBytes() []byte
ToBytes outputs as byte slice. 输出字节切片
func (BaseStruct) ToHexBytes ¶
func (e BaseStruct) ToHexBytes() []byte
ToHexBytes outputs as byte with hex encoding. 输出经过 hex 编码的字节切片
func (BaseStruct) ToHexString ¶
func (e BaseStruct) ToHexString() string
ToHexString outputs as string with hex encoding. 输出经过 hex 编码的字符串
func (BaseStruct) ToString ¶
func (e BaseStruct) ToString() string
ToString outputs as string. 输出字符串
type Cipher ¶
type Cipher struct { PublicKey []byte // 公钥 PrivateKey []byte // 私钥 Err error // contains filtered or unexported fields }
Cipher defines a Cipher struct. 定义 Cipher 结构体
func (*Cipher) PKCS5Padding ¶
PKCS5Padding padding with PKCS5 mode. 进行 PKCS5 填充
func (*Cipher) PKCS5UnPadding ¶
PKCS5UnPadding removes padding with PKCS5 mode. 移除 PKCS5 填充
func (*Cipher) PKCS7Padding ¶
PKCS7Padding padding with PKCS7 mode. 进行 PKCS7 填充
func (*Cipher) PKCS7UnPadding ¶
PKCS7UnPadding removes padding with PKCS7 mode. 移除 PKCS7 填充
func (*Cipher) RSAGeneratePrivateKey ¶
func (*Cipher) RSAGeneratePublicKey ¶
func (*Cipher) SetPadding ¶
func (c *Cipher) SetPadding(padding PaddingType) *Cipher
SetPadding sets padding. 设置填充模式
func (*Cipher) SetPrivateKey ¶
func (*Cipher) SetPublicKey ¶
func (*Cipher) ZeroPadding ¶
ZeroPadding padding with Zero mode. 进行零填充
func (*Cipher) ZeroUnPadding ¶
ZeroUnPadding removes padding with Zero mode. 移除零填充
type Decrypt ¶
type Decrypt struct {
BaseStruct
}
func NewDecrypt ¶
func NewDecrypt() Decrypt
func (Decrypt) ByTripleDes ¶
ByTripleDes decrypts by aes algorithm. 通过 des 解密
func (Decrypt) FromBase32Byte ¶
func (Decrypt) FromBase32String ¶
func (Decrypt) FromBase64Byte ¶
func (Decrypt) FromBase64String ¶
func (Decrypt) FromHexByte ¶
func (Decrypt) FromHexString ¶
func (Decrypt) FromString ¶
FromString hash from string. 对字符串进行编码
type Encrypt ¶
type Encrypt struct {
BaseStruct
}
func NewEncrypt ¶
func NewEncrypt() Encrypt
func (Encrypt) ByTripleDes ¶
ByTripleDes encrypts by aes algorithm. 通过 des 加密
func (Encrypt) FromString ¶
FromString hash from string. 对字符串进行编码
type ModeType ¶
type ModeType string
ModeType mode constants 模式常量
const ( CBC ModeType = "CBC" ECB ModeType = "ECB" CFB ModeType = "CFB" OFB ModeType = "OFB" CTR ModeType = "CTR" RSA_OAEP_SHA1 ModeType = "RSA_OAEP_SHA1" RSA_OAEP_MD5 ModeType = "RSA_OAEP_MD5" RSA_OAEP_SHA256 ModeType = "RSA_OAEP_SHA256" RSA_OAEP_SHA384 ModeType = "RSA_OAEP_SHA384" RSA_OAEP_SHA512 ModeType = "RSA_OAEP_SHA512" RSA_PKCS1_V1_5 ModeType = "RSA_PKCS1_V1_5" )
func (*ModeType) RsaOaepMD5 ¶
func (*ModeType) RsaOaepSHA1 ¶
func (*ModeType) RsaOaepSHA256 ¶
func (*ModeType) RsaOaepSHA384 ¶
func (*ModeType) RsaOaepSHA512 ¶
type PaddingType ¶
type PaddingType string
PaddingType padding constants 填充常量
const ( No PaddingType = "no" Zero PaddingType = "zero" PKCS5 PaddingType = "pkcs5" PKCS7 PaddingType = "pkcs7" )
func (*PaddingType) No ¶
func (p *PaddingType) No() PaddingType
func (*PaddingType) PKCS5 ¶
func (p *PaddingType) PKCS5() PaddingType
func (*PaddingType) PKCS7 ¶
func (p *PaddingType) PKCS7() PaddingType
func (*PaddingType) Zero ¶
func (p *PaddingType) Zero() PaddingType