cryptor

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 20 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 AbiCoder

func AbiCoder(argTypes []string, argValues []interface{}) ([]byte, error)

func AbiCoderHex

func AbiCoderHex(argTypes []string, argValues []interface{}) (string, error)

func AbiDecoder

func AbiDecoder(argTypes []string, input []byte, argValues []interface{}) error

func AbiDecoderWithReturnedValues

func AbiDecoderWithReturnedValues(argTypes []string, input []byte) ([]interface{}, error)

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 PrivateKeyDecrypt

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

PrivateKeyDecrypt private decrypt

func PrivateKeyEncrypt

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

PrivateKeyEncrypt private encrypt

func PubkeyDecrypt

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

PubkeyDecrypt public decrypt

func PubkeyEncrypt

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

PubkeyEncrypt public encrypt

func RsaPrivateKeyFromBytes

func RsaPrivateKeyFromBytes(privatekey []byte) (*rsa.PrivateKey, error)

RsaPrivateKeyFromBytes get rsa private key from bytes

func RsaPubkeyFromBytes

func RsaPubkeyFromBytes(publickey []byte) (*rsa.PublicKey, error)

RsaPubkeyFromBytes get rsa public key from bytes

func SignMd5WithRsa

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

SignMd5WithRsa Signed using the RSA With MD5 algorithm

func SignSha1WithRsa

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

SignSha1WithRsa Sign with the RSA With SHA1 algorithm

func SignSha256WithRsa

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

SignSha256WithRsa Sign with the RSA With SHA256 algorithm

func VerifySignMd5WithRsa

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

VerifySignMd5WithRsa Verify signatures using RSA With MD 5

func VerifySignSha1WithRsa

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

VerifySignSha1WithRsa Verify the signature using RSA With SHA 1

func VerifySignSha256WithRsa

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

VerifySignSha256WithRsa Verify the signature using RSA With SHA 256

Types

type RSASecurity

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

func (*RSASecurity) PriKeyDecrypt

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

PriKeyDecrypt private key decrypt

func (*RSASecurity) PriKeyEncrypt

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

PriKeyEncrypt private key encrypt

func (*RSASecurity) PrivateKey

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

PrivateKey *rsa.PrivateKey

func (*RSASecurity) PubKeyDecrypt

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

PubKeyDecrypt pubkey decrypt

func (*RSASecurity) PubKeyEncrypt

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

PubKeyEncrypt pubkey encrypt

func (*RSASecurity) PublicKey

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

PublicKey *rsa.PublicKey

func (*RSASecurity) SetPrivateKey

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

SetPrivateKey set private key

func (*RSASecurity) SetPublicKey

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

SetPublicKey set public key

func (*RSASecurity) SignMd5WithRsa

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

SignMd5WithRsa PriKeySign private key sign by md5

func (*RSASecurity) SignSha1WithRsa

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

SignSha1WithRsa PriKeySign private key sign by sha1

func (*RSASecurity) SignSha256WithRsa

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

SignSha256WithRsa PriKeySign private key sign by sha256

func (*RSASecurity) VerifySignMd5WithRsa

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

VerifySignMd5WithRsa PubKeyVerifySign public key verify sign by md5

func (*RSASecurity) VerifySignSha1WithRsa

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

VerifySignSha1WithRsa PubKeyVerifySign public key verify sign by sha1

func (*RSASecurity) VerifySignSha256WithRsa

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

VerifySignSha256WithRsa PubKeyVerifySign public key verify sign by sha256

Jump to

Keyboard shortcuts

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