Documentation ¶
Index ¶
- Constants
- Variables
- type Crypt
- func (c *Crypt) Decrypt(input []byte, typ DecryptType) ([]byte, error)
- func (c *Crypt) Encrypt(input []byte, typ EncryptType) ([]byte, error)
- func (c *Crypt) GetPriKey() (*rsa.PrivateKey, error)
- func (c *Crypt) GetPubKey() (*rsa.PublicKey, error)
- func (c *Crypt) PriKeyDecrypt(input []byte) ([]byte, error)
- func (c *Crypt) PriKeyEncrypt(input []byte) ([]byte, error)
- func (c *Crypt) PubKeyDecrypt(input []byte) ([]byte, error)
- func (c *Crypt) PubKeyEncrypt(input []byte) ([]byte, error)
- func (c *Crypt) SetPriKey(priKey string) (err error)
- func (c *Crypt) SetPubKey(pubKey string) (err error)
- type DecryptType
- type EncryptType
Constants ¶
View Source
const ( PubKeyEncrypt EncryptType = 1 PubKeyDecrypt DecryptType = 2 PriKeyEncrypt EncryptType = 3 PriKeyDecrypt DecryptType = 4 )
Variables ¶
View Source
var ( ErrEncryptTypeNoFound = errors.New("encrypt type no found") ErrDecryptTypeNoFound = errors.New("decrypt type no found") ErrPubKeyNil = errors.New(`please set public key in crypt`) ErrPriKeyNil = errors.New(`please set private key in crypt`) ErrDataToLarge = errors.New("message too long for rsa public key size") ErrDataLen = errors.New("data length error") ErrDataBroken = errors.New("data broken, first byte is not zero") ErrKeyPairMismatch = errors.New("data is not encrypted by private key") ErrDecryption = errors.New("decryption error") ErrGetPubKey = errors.New("get public key error") ErrGetPriKey = errors.New("get private key error") )
View Source
var Crypto = Crypt{}
Functions ¶
This section is empty.
Types ¶
type Crypt ¶
func (*Crypt) PriKeyDecrypt ¶ added in v1.1.0
func (*Crypt) PriKeyEncrypt ¶ added in v1.1.0
func (*Crypt) PubKeyDecrypt ¶ added in v1.1.0
func (*Crypt) PubKeyEncrypt ¶ added in v1.1.0
type DecryptType ¶
type DecryptType uint8
type EncryptType ¶
type EncryptType uint8
Click to show internal directories.
Click to hide internal directories.