rsa

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

type Crypt struct {
	gocrypt.Base64
	// contains filtered or unexported fields
}

func (*Crypt) Decrypt

func (c *Crypt) Decrypt(input []byte, typ DecryptType) ([]byte, error)

func (*Crypt) Encrypt

func (c *Crypt) Encrypt(input []byte, typ EncryptType) ([]byte, error)

func (*Crypt) GetPriKey

func (c *Crypt) GetPriKey() (*rsa.PrivateKey, error)

func (*Crypt) GetPubKey

func (c *Crypt) GetPubKey() (*rsa.PublicKey, error)

func (*Crypt) PriKeyDecrypt added in v1.1.0

func (c *Crypt) PriKeyDecrypt(input []byte) ([]byte, error)

func (*Crypt) PriKeyEncrypt added in v1.1.0

func (c *Crypt) PriKeyEncrypt(input []byte) ([]byte, error)

func (*Crypt) PubKeyDecrypt added in v1.1.0

func (c *Crypt) PubKeyDecrypt(input []byte) ([]byte, error)

func (*Crypt) PubKeyEncrypt added in v1.1.0

func (c *Crypt) PubKeyEncrypt(input []byte) ([]byte, error)

func (*Crypt) SetPriKey

func (c *Crypt) SetPriKey(priKey string) (err error)

func (*Crypt) SetPubKey

func (c *Crypt) SetPubKey(pubKey string) (err error)

type DecryptType

type DecryptType uint8

type EncryptType

type EncryptType uint8

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL