crypto

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultRSAKeySize = 512
)

Variables

This section is empty.

Functions

func DecryptWithPrivateKeyString

func DecryptWithPrivateKeyString(privateKeyStr, cipher string) (string, error)

DecryptWithPrivateKeyString decrypts the data with private key string

func DecryptWithPublicKeyString

func DecryptWithPublicKeyString(publicKeyStr, cipher string) (string, error)

DecryptWithPublicKeyString decrypts the data with public key string

func EncryptWithPrivateKeyString

func EncryptWithPrivateKeyString(privateKeyStr, message string) (string, error)

EncryptWithPrivateKeyString encrypts the data with private key string

func EncryptWithPublicKeyString

func EncryptWithPublicKeyString(publicKeyStr, message string) (string, error)

EncryptWithPublicKeyString encrypts the data with public key string

Types

type RSA

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

func NewEmptyRSA

func NewEmptyRSA() *RSA

NewEmptyRSA returns a new *RSA

func NewRSA

func NewRSA() (*RSA, error)

NewRSA returns a new *RSA

func NewRSAWithKeySize

func NewRSAWithKeySize(size int) (*RSA, error)

NewRSAWithKeySize returns a new *RSA with given key size

func NewRSAWithPrivateKey

func NewRSAWithPrivateKey(privateKey *rsa.PrivateKey) *RSA

NewRSAWithPrivateKey returns a new *RSA with given private key

func NewRSAWithPrivateKeyString

func NewRSAWithPrivateKeyString(privateKeyStr string) (*RSA, error)

NewRSAWithPrivateKeyString returns a new *RSA with given private key base64 string

func (*RSA) Decrypt

func (r *RSA) Decrypt(cipher string) (string, error)

Decrypt decrypts the base64 string

func (*RSA) DecryptWithPrivateKey

func (r *RSA) DecryptWithPrivateKey(cipher string) (string, error)

DecryptWithPrivateKey decrypts the cipher with private key

func (*RSA) DecryptWithPublicKey

func (r *RSA) DecryptWithPublicKey(cipher string) (string, error)

DecryptWithPublicKey decrypts the cipher with public key

func (*RSA) Encrypt

func (r *RSA) Encrypt(message string) (string, error)

Encrypt encrypts the string and returns the base64 string

func (*RSA) EncryptWithPrivateKey

func (r *RSA) EncryptWithPrivateKey(message string) (string, error)

EncryptWithPrivateKey encrypts the message with private key

func (*RSA) EncryptWithPublicKey

func (r *RSA) EncryptWithPublicKey(message string) (string, error)

EncryptWithPublicKey encrypts the message with public key

func (*RSA) GetPrivateKey

func (r *RSA) GetPrivateKey() (string, error)

GetPrivateKey gets the private key base64 string

func (*RSA) GetPublicKey

func (r *RSA) GetPublicKey() (string, error)

GetPublicKey gets the public key base64 string

func (*RSA) SetPrivateKey

func (r *RSA) SetPrivateKey(privateKeyStr string) error

SetPrivateKey sets the private key with base64 string

func (*RSA) SetPublicKey

func (r *RSA) SetPublicKey(publicKeyStr string) error

SetPublicKey sets the public key with base64 string

Jump to

Keyboard shortcuts

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