crypto

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aes

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

func (*Aes) Decrypt

func (ae *Aes) Decrypt(data string, key, iv string) (string, error)

Decrypt 解密为字符串 Decrypt data hex编码的加密后结果 Decrypt key hex编码的16位或32位密钥 Decrypt iv hex编码的16位或32位向量 Decrypt return 解密后的数据,string类型

func (*Aes) DecryptBytes

func (ae *Aes) DecryptBytes(data, key, iv []byte) ([]byte, error)

DecryptBytes 解密为二进制数据 DecryptBytes data 二进制的加密后结果 DecryptBytes key 二进制的16位或32位密钥 DecryptBytes iv 二进制的16位或32位向量 DecryptBytes return 解密后的数据,二进制的字节数组

func (*Aes) Encrypt

func (ae *Aes) Encrypt(data, key, iv string) (string, error)

Encrypt 将字符串加密 Encrypt data 用于加密的数据,string类型 Encrypt key hex编码的16位或32位密钥 Encrypt iv hex编码的16位或32位向量 Encrypt return 返回hex编码的加密结果

func (*Aes) EncryptBytes

func (ae *Aes) EncryptBytes(data, key, iv []byte) ([]byte, error)

EncryptBytes 将二进制数据加密 EncryptBytes data 用于加密的数据,二进制的字节数组 EncryptBytes key 二进制的16位或32位密钥 EncryptBytes iv 二进制的16位或32位向量 EncryptBytes return 返回二进制的加密结果

type Ecdsa

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

func (*Ecdsa) Decrypt

func (ec *Ecdsa) Decrypt(data string, priKey string) (string, error)

Decrypt priKey hex编码的私钥信息

func (*Ecdsa) DecryptBytes

func (ec *Ecdsa) DecryptBytes(data, priKey []byte) ([]byte, error)

DecryptBytes priKey 二进制的私钥信息

func (*Ecdsa) Encrypt

func (ec *Ecdsa) Encrypt(data, pubKey string) (string, error)

Encrypt pubKey hex编码的公钥信息

func (*Ecdsa) EncryptBytes

func (ec *Ecdsa) EncryptBytes(data, pubKey []byte) ([]byte, error)

EncryptBytes pubKey 二进制的公钥信息

func (*Ecdsa) GenKey

func (ec *Ecdsa) GenKey() (priKey string, pubKey string, error error)

GenKey 生成hex编码的公钥私钥 GenKey priKey hex编码的私钥信息 GenKey pubKey hex编码的公钥信息

func (*Ecdsa) GenKeyBytes

func (ec *Ecdsa) GenKeyBytes() (priKey []byte, pubKey []byte, error error)

GenKeyBytes 生成二进制的公钥私钥 GenKeyBytes priKey 二进制的私钥信息 GenKeyBytes pubKey 二进制的公钥信息

func (*Ecdsa) Sign

func (ec *Ecdsa) Sign(data string, priKey string) (string, error)

Sign 对数据进行签名,返回hex编码格式的数据 Sign data 将要签名的数据 Sign priKey hex编码的私钥信息

func (*Ecdsa) SignBytes

func (ec *Ecdsa) SignBytes(data, priKey []byte) ([]byte, error)

SignBytes 对数据进行签名,返回二进制的数据 SignBytes data 将要签名的二进制数据 SignBytes priKey 二进制的私钥信息

func (*Ecdsa) Verify

func (ec *Ecdsa) Verify(data string, signature string, pubKey string) (bool, error)

Verify 校验签名 Verify data 将要签名的数据 Verify signature hex编码的签名信息 Verify pubKey hex编码的公钥信息 Verify return 校验结果

func (*Ecdsa) VerifyBytes

func (ec *Ecdsa) VerifyBytes(data, signature, pubKey []byte) bool

VerifyBytes 校验签名 VerifyBytes data 将要签名的二进制数据 VerifyBytes signature 二进制的签名信息 VerifyBytes pubKey 二进制的公钥信息 VerifyBytes return 校验结果

type Hash

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

func (*Hash) Add

func (hash *Hash) Add(data string) *Hash

Add 添加数据到Hash Add data 字符串格式的数据 Add return Hash对象,方便串联操作

func (*Hash) AddBytes

func (hash *Hash) AddBytes(p []byte) *Hash

AddBytes 添加二进制数据到Hash AddBytes data 二进制数据 AddBytes return Hash对象,方便串联操作

func (*Hash) AddHex

func (hash *Hash) AddHex(data string) *Hash

AddHex 添加Hex编码的数据到Hash AddHex data Hex编码的二进制数据 AddHex return Hash对象,方便串联操作

func (*Hash) Make

func (hash *Hash) Make() string

Make 生成Hash Make return Hex编码的结果

func (*Hash) MakeBytes

func (hash *Hash) MakeBytes() []byte

MakeBytes 生成Hash MakeBytes return 二进制结果

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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