Documentation ¶
Index ¶
- Variables
- func PriKeyDecrypt(data, privateKey string) (string, error)
- func PriKeyEncrypt(data, privateKey string) (string, error)
- func PublicDecrypt(data, publicKey string) (string, error)
- func PublicEncrypt(data, publicKey string) (string, error)
- func SignSha1WithRsa(data string, privateKey string) (string, error)
- func SignSha256WithRsa(data string, privateKey string) (string, error)
- func VerifySignSha1WithRsa(data string, signData string, publicKey string) error
- func VerifySignSha256WithRsa(data string, signData string, publicKey string) error
- type RSASecurity
- func (rsas *RSASecurity) GetPrivatekey() (*rsa.PrivateKey, error)
- func (rsas *RSASecurity) GetPublickey() (*rsa.PublicKey, error)
- func (rsas *RSASecurity) PriKeyDECRYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PriKeyENCTYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PubKeyDECRYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) PubKeyENCTYPT(input []byte) ([]byte, error)
- func (rsas *RSASecurity) SetPrivateKey(priStr string) (err error)
- func (rsas *RSASecurity) SetPublicKey(pubStr string) (err error)
- func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)
- func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)
- func (rsas *RSASecurity) VerifySignSha1WithRsa(data string, signData string) error
- func (rsas *RSASecurity) VerifySignSha256WithRsa(data string, signData string) error
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 SignSha1WithRsa ¶
使用RSAWithSHA1算法签名
func SignSha256WithRsa ¶
使用RSAWithSHA256算法签名
func VerifySignSha1WithRsa ¶
使用RSAWithSHA1验证签名
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) SignSha1WithRsa ¶
func (rsas *RSASecurity) SignSha1WithRsa(data string) (string, error)
*
- 使用RSAWithSHA1算法签名
func (*RSASecurity) SignSha256WithRsa ¶
func (rsas *RSASecurity) SignSha256WithRsa(data string) (string, error)
*
- 使用RSAWithSHA256算法签名
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验证签名
Click to show internal directories.
Click to hide internal directories.