codec

package
v1.0.12-0...-16f252f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPriKey    = errors.New("invalid private key")
	ErrInvalidPubKey    = errors.New("invalid public key")
	ErrPubKeyOutOfBound = errors.New("public key out of bound")
)
View Source
var (
	ErrPrivateKey = errors.New("private key error")
	ErrPublicKey  = errors.New("failed to parse PEM block containing the public key")
	ErrNotRsaKey  = errors.New("key type is not RSA")
)
View Source
var ErrPaddingSize = errors.New("padding size error")

Functions

func ComputeKey

func ComputeKey(pubKey, priKey *big.Int) (*big.Int, error)

func EcbDecrypt

func EcbDecrypt(key, src []byte) ([]byte, error)

func EcbDecryptBase64

func EcbDecryptBase64(key, src string) (string, error)

func EcbEncrypt

func EcbEncrypt(key, src []byte) ([]byte, error)

func EcbEncryptBase64

func EcbEncryptBase64(key, src string) (string, error)

func Gunzip

func Gunzip(bs []byte) ([]byte, error)

func Gzip

func Gzip(bs []byte) []byte

func Hmac

func Hmac(key []byte, body string) []byte

func HmacBase64

func HmacBase64(key []byte, body string) string

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

func NewPublicKey

func NewPublicKey(bs []byte) *big.Int

Types

type DhKey

type DhKey struct {
	PriKey *big.Int
	PubKey *big.Int
}

func GenerateKey

func GenerateKey() (*DhKey, error)

func (*DhKey) Bytes

func (k *DhKey) Bytes() []byte

type RsaDecrypter

type RsaDecrypter interface {
	Decrypt(input []byte) ([]byte, error)
	DecryptBase64(input string) ([]byte, error)
}

func NewRsaDecrypter

func NewRsaDecrypter(file string) (RsaDecrypter, error)

type RsaEncrypter

type RsaEncrypter interface {
	Encrypt(input []byte) ([]byte, error)
}

func NewRsaEncrypter

func NewRsaEncrypter(key []byte) (RsaEncrypter, error)

Jump to

Keyboard shortcuts

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