Documentation ¶
Index ¶
- type Crypt
- type Encode
- type HandleFunc
- type Hash
- type RSACrypt
- func (rc *RSACrypt) Decrypt(inputData string, inputDataType Encode) (string, error)
- func (rc *RSACrypt) Encrypt(inputData string, outputDataType Encode) (string, error)
- func (rc *RSACrypt) New() HandleFunc
- func (rc *RSACrypt) Sign(inputData string, hashType Hash, outputDataType Encode) (string, error)
- func (rc *RSACrypt) VerifySign(inputData string, hashType Hash, signData string, signDataType Encode) (bool, error)
- type Secret
- type SecretInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandleFunc ¶
type HandleFunc interface { New() HandleFunc Encrypt(inputData string, outputDataType Encode) (string, error) Decrypt(inputData string, inputDataType Encode) (string, error) Sign(inputData string, hashType Hash, outputDataType Encode) (string, error) VerifySign(inputData string, hashType Hash, signData string, signDataType Encode) (bool, error) // contains filtered or unexported methods }
HandleFunc defines the common func for crypt
func NewCrypt ¶
func NewCrypt(cryptType Crypt, secretInfo SecretInfo) (HandleFunc, error)
NewCrypt new a HandleFunc for the adapterType with the secret info cryptType the crypt type secretInfo private & public key info
type RSACrypt ¶
type RSACrypt struct {
// contains filtered or unexported fields
}
func (*RSACrypt) Decrypt ¶
Decrypt decrypts a plaintext using private key inputData the encrypted data with public key inputDataType the encode type of encrypted data ,such as Base64,HEX
func (*RSACrypt) Encrypt ¶
Encrypt encrypts the given message with public key inputData the original data outputDataType the encode type of encrypted data ,such as Base64,HEX
func (*RSACrypt) New ¶
func (rc *RSACrypt) New() HandleFunc
func (*RSACrypt) Sign ¶
Sign calculates the signature of input data with the hash type & private key inputData the 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(inputData string, hashType Hash, signData string, signDataType Encode) (bool, error)
VerifySign verifies input data whether match the sign data with the public key inputData the unsigned data signData the unsigned 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