rsa

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharSet          = "UTF-8"
	Base64Format     = "UrlSafeNoPadding"
	AlgorithmKeyType = "PKCS1"
	AlgorithmSign    = crypto.SHA256
	Bits             = 2048
)

Variables

View Source
var Base64Encoding *base64.Encoding

Functions

func CreateKeys

func CreateKeys(publicKeyWriter, privateKeyWriter io.Writer, keyLengths ...int) error

生成密钥对

func CreateKeysToBase64

func CreateKeysToBase64(keyLengths ...int) (string, string, error)

func CreateKeysToBytes

func CreateKeysToBytes(keyLengths ...int) ([]byte, []byte, error)

func MarshalPKCS8PrivateKey

func MarshalPKCS8PrivateKey(key *rsa.PrivateKey) ([]byte, error)

Types

type XRsa

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

func NewXRsa

func NewXRsa(publicKey []byte, privateKey []byte) (*XRsa, error)

func (*XRsa) Decrypt

func (r *XRsa) Decrypt(encrypted []byte) ([]byte, error)

私钥解密

func (*XRsa) DecryptFromBase64

func (r *XRsa) DecryptFromBase64(encrypted string) ([]byte, error)

func (*XRsa) Encrypt

func (r *XRsa) Encrypt(data []byte) ([]byte, error)

公钥加密

func (*XRsa) EncryptToBase64

func (r *XRsa) EncryptToBase64(data []byte) (string, error)

func (*XRsa) Sign

func (r *XRsa) Sign(data []byte) ([]byte, error)

私钥签名

func (*XRsa) SignToBase64

func (r *XRsa) SignToBase64(data []byte) (string, error)

数据签名

func (*XRsa) Verify

func (r *XRsa) Verify(data []byte, sign []byte) error

公钥验签

func (*XRsa) VerifyFromBase64

func (r *XRsa) VerifyFromBase64(data []byte, sign string) error

Jump to

Keyboard shortcuts

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