cryptor

package
v0.0.0-...-28d388b Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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")
	ErrKeyPairDismatch = errors.New("data is not encrypted by the private key")
	ErrDecryption      = errors.New("decryption error")
	ErrPublicKey       = errors.New("get public key error")
	ErrPrivateKey      = errors.New("get private key error")
)
View Source
var RSA = &RSASecurity{}

Functions

func AesDecryptByECB

func AesDecryptByECB(data, key []byte) []byte

AesDecryptByECB ---------------AES ECB解密-------------------- data: 密文数据 key: 密钥字符串 返回明文数据

func AesDecryptByECBBase64

func AesDecryptByECBBase64(data, key string) string

AesDecryptByECBBase64 ---------------AES ECB解密 Base64-------------------- data: 密文数据 key: 密钥字符串 返回明文数据

func AesEncryptByECB

func AesEncryptByECB(data, key []byte) []byte

AesEncryptByECB ---------------AES ECB加密-------------------- data: 明文数据 key: 密钥字符串 返回密文数据

func AesEncryptByECBBase64

func AesEncryptByECBBase64(data, key string) string

AesEncryptByECBBase64 ---------------AES ECB加密 Base64-------------------- data: 明文数据 key: 密钥字符串 返回密文数据

func DesCBCDecrypter

func DesCBCDecrypter(data, key, iv []byte) []byte

DesCBCDecrypter ---------------DES CBC解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据

func DesCBCEncrypt

func DesCBCEncrypt(data, key, iv []byte) []byte

DesCBCEncrypt ---------------DES CBC加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据

func DesCFBDecrypter

func DesCFBDecrypter(data, key, iv []byte) []byte

DesCFBDecrypter ---------------DES CFB解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据

func DesCFBEncrypt

func DesCFBEncrypt(data, key, iv []byte) []byte

DesCFBEncrypt ---------------DES CFB加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据

func DesCTRDecrypter

func DesCTRDecrypter(data, key, iv []byte) []byte

DesCTRDecrypter ---------------DES CTR解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据

func DesCTREncrypt

func DesCTREncrypt(data, key, iv []byte) []byte

DesCTREncrypt ---------------DES CTR加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据

func DesECBDecrypter

func DesECBDecrypter(data, key []byte) []byte

DesECBDecrypter ---------------DES ECB解密-------------------- data: 密文数据 key: 密钥字符串 返回明文数据

func DesECBEncrypt

func DesECBEncrypt(data, key []byte) []byte

DesECBEncrypt ---------------DES ECB加密-------------------- data: 明文数据 key: 密钥字符串 返回密文数据

func DesOFBDecrypter

func DesOFBDecrypter(data, key, iv []byte) []byte

DesOFBDecrypter ---------------DES OFB解密-------------------- data: 密文数据 key: 密钥字符串 iv:iv向量 返回明文数据

func DesOFBEncrypt

func DesOFBEncrypt(data, key, iv []byte) []byte

DesOFBEncrypt ---------------DES OFB加密-------------------- data: 明文数据 key: 密钥字符串 iv:iv向量 返回密文数据

func GenerateRandomPass

func GenerateRandomPass(length, numDigits, numSymbols int, noUpper, allowRepeat bool) (string, error)

GenerateRandomPass 随机生成安全的密码

func PriKeyDecrypt

func PriKeyDecrypt(data, privateKey string) (string, error)

私钥解密

func PriKeyEncrypt

func PriKeyEncrypt(data, privateKey string) (string, error)

私钥加密

func PublicDecrypt

func PublicDecrypt(data, publicKey string) (string, error)

公钥解密

func PublicEncrypt

func PublicEncrypt(data, publicKey string) (string, error)

公钥加密

func SignMd5WithRsa

func SignMd5WithRsa(data string, privateKey string) (string, error)

使用RSAWithMD5算法签名

func SignSha1WithRsa

func SignSha1WithRsa(data string, privateKey string) (string, error)

使用RSAWithSHA1算法签名

func SignSha256WithRsa

func SignSha256WithRsa(data string, privateKey string) (string, error)

使用RSAWithSHA256算法签名

func VerifySignMd5WithRsa

func VerifySignMd5WithRsa(data string, signData string, publicKey string) error

使用RSAWithMD5验证签名

func VerifySignSha1WithRsa

func VerifySignSha1WithRsa(data string, signData string, publicKey string) error

使用RSAWithSHA1验证签名

func VerifySignSha256WithRsa

func VerifySignSha256WithRsa(data string, signData string, publicKey string) error

使用RSAWithSHA256验证签名

Types

type RSASecurity

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

func (*RSASecurity) GetPrivatekey

func (rsas *RSASecurity) GetPrivatekey() (*rsa.PrivateKey, error)

*rsa.PublicKey

func (*RSASecurity) GetPublickey

func (rsas *RSASecurity) GetPublickey() (*rsa.PublicKey, error)

*rsa.PrivateKey

func (*RSASecurity) PriKeyDECRYPT

func (rsas *RSASecurity) PriKeyDECRYPT(input []byte) ([]byte, error)

私钥解密

func (*RSASecurity) PriKeyENCTYPT

func (rsas *RSASecurity) PriKeyENCTYPT(input []byte) ([]byte, error)

私钥加密

func (*RSASecurity) PubKeyDECRYPT

func (rsas *RSASecurity) PubKeyDECRYPT(input []byte) ([]byte, error)

公钥解密

func (*RSASecurity) PubKeyENCTYPT

func (rsas *RSASecurity) PubKeyENCTYPT(input []byte) ([]byte, error)

公钥加密

func (*RSASecurity) SetPrivateKey

func (rsas *RSASecurity) SetPrivateKey(priStr string) (err error)

设置私钥

func (*RSASecurity) SetPublicKey

func (rsas *RSASecurity) SetPublicKey(pubStr string) (err error)

设置公钥

func (*RSASecurity) SignMd5WithRsa

func (rsas *RSASecurity) SignMd5WithRsa(data string) (string, error)

*

  • 使用RSAWithMD5算法签名

func (*RSASecurity) SignSha1WithRsa

func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)

*

  • 使用RSAWithSHA1算法签名

func (*RSASecurity) SignSha256WithRsa

func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)

*

  • 使用RSAWithSHA256算法签名

func (*RSASecurity) VerifySignMd5WithRsa

func (rsas *RSASecurity) VerifySignMd5WithRsa(data string, signData string) error

*

  • 使用RSAWithMD5验证签名

func (*RSASecurity) VerifySignSha1WithRsa

func (rsas *RSASecurity) VerifySignSha1WithRsa(data string, signData string) error

*

  • 使用RSAWithSHA1验证签名

func (*RSASecurity) VerifySignSha256WithRsa

func (rsas *RSASecurity) VerifySignSha256WithRsa(data string, signData string) error

*

  • 使用RSAWithSHA256验证签名

Jump to

Keyboard shortcuts

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