rsax

package
v0.0.0-...-afa1935 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RSAAlgorithmSign RSA签名算法
	RSAAlgorithmSign = crypto.SHA256
)

Variables

This section is empty.

Functions

func MarshalPKCS8PrivateKey

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

MarshalPKCS8PrivateKey 私钥解析

func NewRSAFile

func NewRSAFile(pubKeyFileName, priKeyFileName string, keyLength int) error

NewRSAFile 生成密钥对文件 pubKeyFileName: 公钥文件名 priKeyFileName: 私钥文件名 keyLength: 密钥长度

func NewRSAString

func NewRSAString(keyLength int) (string, string, error)

NewRSAString 生成密钥对字符串 keyLength 密钥的长度

func ReadRSAKeyPair

func ReadRSAKeyPair(pubKeyFilename, priKeyFilename string) ([]byte, []byte, error)

ReadRSAKeyPair 读取RSA密钥对 pubKeyFilename: 公钥文件名称 priKeyFilename: 私钥文件名

func WriteRSAKeyPair

func WriteRSAKeyPair(publicKeyWriter, privateKeyWriter io.Writer, keyLength int) error

WriteRSAKeyPair 生成RSA密钥对

Types

type GoRSA

type GoRSA struct {
	PublicKey  *rsa.PublicKey
	PrivateKey *rsa.PrivateKey
}

GoRSA RSA加密解密

func NewGoRSA

func NewGoRSA(pubKeyFilename, priKeyFilename string) (*GoRSA, error)

NewGoRSA 初始化 GoRSA对象

func (*GoRSA) PrivateDecrypt

func (r *GoRSA) PrivateDecrypt(encrypted []byte) ([]byte, error)

PrivateDecrypt 私钥解密

func (*GoRSA) PublicEncrypt

func (r *GoRSA) PublicEncrypt(data []byte) ([]byte, error)

PublicEncrypt 公钥加密

func (*GoRSA) Sign

func (r *GoRSA) Sign(data string) (string, error)

Sign 数据进行签名

func (*GoRSA) Verify

func (r *GoRSA) Verify(data string, sign string) error

Verify 数据验证签名

Jump to

Keyboard shortcuts

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