crypt

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 28 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 AesDecrypt added in v0.3.9

func AesDecrypt(crypted, key []byte) ([]byte, error)

de

func AesEncrypt added in v0.3.9

func AesEncrypt(origData, key []byte) ([]byte, error)

en

func ComputeKey

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

func Decrypt added in v0.3.9

func Decrypt(encrypted []byte, key []byte) (plaintext []byte, err error)

Decrypt using the pre-generated key

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 Encrypt added in v0.3.9

func Encrypt(plaintext []byte, key []byte) (encrypted []byte, err error)

Encrypt will encrypt using the pre-generated key

func GetRandomString added in v0.3.9

func GetRandomString(l int) string

Generating Random Verification Key

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 InitTls added in v0.3.9

func InitTls()

func Md5 added in v0.3.9

func Md5(s string) string

Generate 32-bit MD5 strings

func New added in v0.3.9

func New(passphrase []byte, usersalt []byte) (key []byte, salt []byte, err error)

New generates a new key based on a passphrase and salt

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

func NewTlsClientConn added in v0.3.9

func NewTlsClientConn(conn net.Conn) net.Conn

func NewTlsServerConn added in v0.3.9

func NewTlsServerConn(conn net.Conn) net.Conn

func PKCS5Padding added in v0.3.9

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

Completion when the length is insufficient

func PKCS5UnPadding added in v0.3.9

func PKCS5UnPadding(origData []byte) (error, []byte)

Remove excess

Types

type ClientHelloMsg added in v0.3.9

type ClientHelloMsg struct {
	// contains filtered or unexported fields
}

func (*ClientHelloMsg) GetServerName added in v0.3.9

func (m *ClientHelloMsg) GetServerName() string

func (*ClientHelloMsg) Unmarshal added in v0.3.9

func (m *ClientHelloMsg) Unmarshal(data []byte) bool

type CurveID added in v0.3.9

type CurveID uint16

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)

type SignatureScheme added in v0.3.9

type SignatureScheme uint16

Jump to

Keyboard shortcuts

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