rsa

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PKCS1            = "RSA PRIVATE KEY"
	// PKCS8            = "PRIVATE KEY"
	PUBKEY           = "PUBLIC KEY"
	RSAAlgorithmSign = crypto.SHA256
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(path string, msg []byte) ([]byte, error)

RSA解密 path 私钥匙文件地址 msg 要解密的数据

func Encrypt

func Encrypt(path string, msg []byte) ([]byte, error)

RSA加密 path 公钥匙文件地址 msg 要加密的数据

func GenerateKeyFile

func GenerateKeyFile(bits int, pkcs PKCS, privateKeyPath, publicKeyPath, certPath string) error

生成密钥对

func ParsePrivateKey

func ParsePrivateKey(path string) (*rsa.PrivateKey, error)

通过pem文件生成rsa私钥

func ParsePublicKey

func ParsePublicKey(path string) (*rsa.PublicKey, error)

通过pem文件生成rsa公钥

func Sign

func Sign(path string, msg []byte) ([]byte, error)

RSA签名 path 私钥匙文件地址 msg 要解密的数据

func SignSHA256 added in v1.0.8

func SignSHA256(path string, msg []byte) ([]byte, error)

func Verify

func Verify(path string, msg, sign []byte) bool

RSA验签 path 公钥匙文件地址 msg 解密的数据 sign 签名的数据

func VerifySHA256 added in v1.0.8

func VerifySHA256(path string, msg, sign []byte) bool

RSA验签 path 公钥匙文件地址 msg 解密的数据 sign 签名的数据

Types

type PKCS

type PKCS int
const (
	PKCS1 PKCS = iota
	PKCS8
)

Jump to

Keyboard shortcuts

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