xrsa

package
v0.0.0-...-26e1b9e Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 14 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 PriKeyDecrypt

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

PriKeyDecrypt 私钥解密

func PriKeyEncrypt

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

PriKeyEncrypt 私钥加密

func PublicDecrypt

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

PublicDecrypt 公钥解密

func PublicEncrypt

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

PublicEncrypt 公钥加密

func SignMd5WithRsa

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

SignMd5WithRsa 使用md5WithSHA1算法签名

func SignSha1WithRsa

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

SignSha1WithRsa 使用RSAWithSHA1算法签名

func SignSha256WithRsa

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

SignSha256WithRsa 使用RSAWithSHA256算法签名

func VerifySignMd5WithRsa

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

VerifySignMd5WithRsa 使用RSAWithMd5验证签名

func VerifySignSha1WithRsa

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

VerifySignSha1WithRsa 使用RSAWithSHA1验证签名

func VerifySignSha256WithRsa

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

VerifySignSha256WithRsa 使用RSAWithSHA256验证签名

Types

type RSASecurity

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

func (*RSASecurity) GetPrivatekey

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

GetPrivatekey *rsa.PublicKey

func (*RSASecurity) GetPublickey

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

GetPublickey *rsa.PrivateKey

func (*RSASecurity) PriKeyDECRYPT

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

PriKeyDECRYPT 私钥解密

func (*RSASecurity) PriKeyENCTYPT

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

PriKeyENCTYPT 私钥加密

func (*RSASecurity) PubKeyDECRYPT

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

PubKeyDECRYPT 公钥解密

func (*RSASecurity) PubKeyENCTYPT

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

PubKeyENCTYPT 公钥加密

func (*RSASecurity) SetPrivateKey

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

SetPrivateKey 设置私钥

func (*RSASecurity) SetPublicKey

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

SetPublicKey 设置公钥

func (*RSASecurity) SignMd5WithRsa

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

SignMd5WithRsa 使用RSAWithMd5算法签名

func (*RSASecurity) SignSha1WithRsa

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

SignSha1WithRsa 使用RSAWithSHA1算法签名

func (*RSASecurity) SignSha256WithRsa

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

SignSha256WithRsa 使用RSAWithSHA256算法签名

func (*RSASecurity) VerifySignMd5WithRsa

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

VerifySignMd5WithRsa 使用RSAWithSHA256验证签名

func (*RSASecurity) VerifySignSha1WithRsa

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

VerifySignSha1WithRsa 使用RSAWithSHA1验证签名

func (*RSASecurity) VerifySignSha256WithRsa

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

VerifySignSha256WithRsa 使用RSAWithSHA256验证签名

Jump to

Keyboard shortcuts

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