rsaKit

package
v2.1.24 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data, privateKey []byte, options ...RsaOption) ([]byte, error)

Decrypt 私钥解密

@param options 可配置: format、password

func Encrypt

func Encrypt(data, publicKey []byte) ([]byte, error)

Encrypt 公钥加密

func GenerateKeyFiles

func GenerateKeyFiles(bits int, priPath, pubPath string, options ...RsaOption) error

GenerateKeyFiles 生成: 公钥 && 私钥

@param bits 512 ||1024 || 2048 || 3072 || 4096 @param options 可配置: format、password

func GenerateKeys

func GenerateKeys(bits int, options ...RsaOption) (pri []byte, pub []byte, err error)

Types

type KeyFormat

type KeyFormat uint8
const (
	PKCS1 KeyFormat = 1
	PKCS8 KeyFormat = 8
)

func (KeyFormat) String

func (format KeyFormat) String() string

type RsaOption

type RsaOption func(opts *rsaOptions)

func WithFormat

func WithFormat(format KeyFormat) RsaOption

WithFormat 配置: 密钥格式(私钥)

func WithPassword

func WithPassword(password string) RsaOption

WithPassword 配置: 私钥密码(可以为"")

Jump to

Keyboard shortcuts

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