rsa

package
v0.0.0-...-ea7d51e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func NewRSACrypt(secret *RSASecret) *RSACrypt

NewRSACrypt init with the RSA secret info

func (*RSACrypt) Decrypt

func (r *RSACrypt) Decrypt(src string, srcType crypt.Encode) (dst string, err error)

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

func (r *RSACrypt) Encrypt(src []byte, outputDataType crypt.Encode) (dst string, err error)

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

type RSASecret

type RSASecret struct {
	PublicKey          string
	PublicKeyDataType  crypt.Encode
	PrivateKey         string
	PrivateKeyDataType crypt.Encode
	PrivateKeyType     crypt.Secret
}

Jump to

Keyboard shortcuts

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