Documentation ¶
Index ¶
- type RSACrypt
- func (r *RSACrypt) Decrypt(src string, srcType crypt.Encode) (dst string, err error)
- func (r *RSACrypt) Encrypt(src []byte, outputDataType crypt.Encode) (dst string, err error)
- func (rc *RSACrypt) Sign(src string, hashType crypt.Hash, outputDataType crypt.Encode) (dst string, err error)
- func (rc *RSACrypt) VerifySign(src string, hashType crypt.Hash, signedData string, signDataType crypt.Encode) (bool, error)
- type RSASecret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RSACrypt ¶
type RSACrypt struct {
Secret *RSASecret
}
func NewRSACrypt ¶
NewRSACrypt init with the RSA secret info
func (*RSACrypt) Decrypt ¶
Decrypt decrypts a plaintext using private key src the encrypted data with public key srcType the encode type of encrypted data ,such as Base64,HEX
func (*RSACrypt) Encrypt ¶
Encrypt encrypts the given message with public key src the original data outputDataType the encode type of encrypted data ,such as Base64,HEX
func (*RSACrypt) Sign ¶
func (rc *RSACrypt) Sign(src string, hashType crypt.Hash, outputDataType crypt.Encode) (dst string, err error)
Sign calculates the signature of input data with the hash type & private key src the original unsigned data hashType the type of hash ,such as MD5,SHA1... outputDataType the encode type of sign data ,such as Base64,HEX
func (*RSACrypt) VerifySign ¶
func (rc *RSACrypt) VerifySign(src string, hashType crypt.Hash, signedData string, signDataType crypt.Encode) (bool, error)
VerifySign verifies input data whether match the sign data with the public key src the original unsigned data signedData the data signed with private key hashType the type of hash ,such as MD5,SHA1... signDataType the encode type of sign data ,such as Base64,HEX