rsa

package
v0.0.0-...-256bcdb Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText, privateKey string) (plainText string, err error)

Decrypt 私钥解密

func Encrypt

func Encrypt(plainText, publicKey string) (cipherText string, err error)

Encrypt 公钥加密

func NewKeyPair

func NewKeyPair(length ...int) (publicKey, privateKey string, err error)

NewKeyPair 生成密钥对

Types

type Security

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

func NewSecurity

func NewSecurity(publicKey, privateKey string) (*Security, error)

NewSecurity 根据指定的 RSA 密钥对创建 Security。

公钥或者私钥可以设置为空,但这种情况下无法使用相应的功能。

func (*Security) Decrypt

func (this *Security) Decrypt(cipherText string) (string, error)

Decrypt 私钥解密

func (*Security) Encrypt

func (this *Security) Encrypt(plainText string) (string, error)

Encrypt 公钥加密

func (*Security) PrivateKey

func (this *Security) PrivateKey() string

func (*Security) PublicKey

func (this *Security) PublicKey() string

func (*Security) SetKey

func (this *Security) SetKey(publicKey, privateKey string) error

Jump to

Keyboard shortcuts

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