rsa

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(ciphertext, privateKey string) (data string, err error)

Decrypt RSA解密 ciphertext 解密数据原串 privateKey 解密时候用到的秘钥 pkcsType 密钥格式类型:PKCS1,PKCS8

func Encrypt

func Encrypt(plainText, publicKey string) (data string, err error)

Encrypt RSA加密 plainText 加密原串 publicKey 加密时候用到的公钥 pkcsType 密钥格式类型:PKCS1,PKCS8

func GenerateKey

func GenerateKey(bits int) (prikey string, pubkey string, err error)

GenerateKey 生成基于pkcs1的rsa私、公钥对 bits 密钥位数:1024,2048

func RegHashMode added in v0.1.16

func RegHashMode(mode string, creator func() (crypto.Hash, hash.Hash))

func Sign

func Sign(data, privateKey, mode string) (string, error)

Sign 使用RSA生成签名 data 签名数据原串 privateKey 签名时候用到的秘钥 mode 加密的模式[目前只支持MD5,SHA1,SHA256,不区分大小写] pkcsType 密钥格式类型:PKCS1,PKCS8

func Verify

func Verify(data, sign, publicKey, mode string) (pass bool, err error)

Verify 校验签名 src 签名认证数据原串 sign 签名串 publicKey 验证签名的公钥 mode 加密的模式[目前只支持MD5,SHA1,SHA256,不区分大小写] pkcsType 密钥格式类型:PKCS1,PKCS8

Types

type Option

type Option func(*options)

Jump to

Keyboard shortcuts

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