rsaKit

package
v3.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data, pemData []byte, password string) ([]byte, error)

Decrypt 私钥解密

支持: PKCS1、PKCS8.

func DecryptPrivatePEM

func DecryptPrivatePEM(pemData []byte, format KeyFormat, password string) ([]byte, error)

DecryptPrivatePEM 通过password,解密私钥(.pem格式)

input: pem raw output: pem raw

func Encrypt

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

Encrypt 公钥加密.

支持: PKCS1、PKCS8.

func EncryptPrivatePEM

func EncryptPrivatePEM(pemData []byte, format KeyFormat, password string) ([]byte, error)

EncryptPrivatePEM 加密私钥(通过password)

input: pem raw output: pem raw

func GenerateKeyFiles

func GenerateKeyFiles(bits int, format KeyFormat, password, priPath, pubPath string, perm os.FileMode) error

GenerateKeyFiles 生成: 公钥 && 私钥

@param bits 512 ||1024 || 2048 || 3072 || 4096 @param format PKCS1 || PKCS8 @param password 私钥的密码(没有则传"") @param priPath 生成私钥文件的位置 @param pubPath 生成公钥文件的位置

func GenerateKeys

func GenerateKeys(bits int, format KeyFormat, password string) (pri []byte, pub []byte, err error)

func ParsePrivateKeyFromPem

func ParsePrivateKeyFromPem(data []byte, password string) (*rsa.PrivateKey, error)

ParsePrivateKeyFromPem 解析私钥.

支持: PKCS1、PKCS8.

@param password 私钥的密码("": 无密码)

func ParsePublicKeyFromPem

func ParsePublicKeyFromPem(pemData []byte) (*rsa.PublicKey, error)

ParsePublicKeyFromPem 解析公钥.

支持: PKCS1、PKCS8.

Types

type KeyFormat

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

func (KeyFormat) String

func (format KeyFormat) String() string

Jump to

Keyboard shortcuts

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