rsa

package
v0.0.0-...-4dec521 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RSASecret

type RSASecret struct {
	PublicKey          string
	PublicKeyDataType  gocrypt.Encode
	PrivateKey         string
	PrivateKeyDataType gocrypt.Encode
	PrivateKeyType     gocrypt.Secret
	MaxEncryptBlock    int
	MaxDecryptBlock    int
}

type RsaCrypt

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

func NewRSACrypt

func NewRSACrypt(secretInfo RSASecret) (*RsaCrypt, error)

NewRSACrypt init with the RSA secret info

func (*RsaCrypt) Decrypt

func (rc *RsaCrypt) Decrypt(src string, srcType gocrypt.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) DecryptBlock

func (rc *RsaCrypt) DecryptBlock(src string, srcType gocrypt.Encode) (bytesDecrypt string, err error)

分段解密

func (*RsaCrypt) Encrypt

func (rc *RsaCrypt) Encrypt(src string, outputDataType gocrypt.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) EncryptBlock

func (rc *RsaCrypt) EncryptBlock(src string, outputDataType gocrypt.Encode) (dst string, err error)

分段加密

func (*RsaCrypt) Sign

func (rc *RsaCrypt) Sign(src string, hashType gocrypt.Hash, outputDataType gocrypt.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 gocrypt.Hash, signedData string, signDataType gocrypt.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

Jump to

Keyboard shortcuts

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