utils

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBase64Str = errors.New("Invalid base64 string")

Functions

func DecryptPKCS1v15

func DecryptPKCS1v15(ciphertext string, privateKey *rsa.PrivateKey) (message string, err error)

DecryptPKCS1v15 使用私钥对PKCS1 padding方式加密的字符串进行解密

func EncryptPKCS1v15WithPublicKey

func EncryptPKCS1v15WithPublicKey(message string, publicKey *rsa.PublicKey) (ciphertext string, err error)

EncryptPKCS1v15WithPublicKey 使用PKCS1 padding方式用公钥进行加密

func GenCertificate

func GenCertificate(bits int) (error error, privateKeyStr, publicKeyStr string)

GenCertificate 生成bits大小的公钥和私钥文本内容(推荐3096大小)

func GenCertificateFile

func GenCertificateFile(bits int) (err error)

GenCertificateFile 生成证书文件

func LoadCertificate

func LoadCertificate(certificateStr string) (certificate *x509.Certificate, err error)

LoadCertificate 通过证书的文本内容加载证书

func LoadPrivateKey

func LoadPrivateKey(privateKeyStr string) (privateKey *rsa.PrivateKey, err error)

LoadPrivateKey 通过私钥的文本内容加载私钥

func LoadPrivateKeyWithPath

func LoadPrivateKeyWithPath(fileName string) (privateKey *rsa.PrivateKey, err error)

LoadPrivateKeyWithPath 通过私钥的文件加载私钥

func LoadPublicKey

func LoadPublicKey(publicKeyStr string) (publicKey *rsa.PublicKey, err error)

LoadPublicKey 通过公钥文本内容加载公钥

func LoadPublicKeyWithPath

func LoadPublicKeyWithPath(fileName string) (privateKey *rsa.PublicKey, err error)

LoadPublicKeyWithPath 通过公钥文件加载公钥

func SignSHA256WithRSA

func SignSHA256WithRSA(source string, privateKy *rsa.PrivateKey) (signature string, err error)

SignSHA256WithRSA 通过私钥对字符以 SHA256WithRSA 算法生成签名信息

func SignSHA256WithRSAUseURLValues

func SignSHA256WithRSAUseURLValues(param url.Values, privateKy *rsa.PrivateKey) (signature string, err error)

SignSHA256WithRSAUseURLValues 通过私钥对 url.Values 以 SHA256WithRSA 算法生成签名信息

func VerifySHA256WithRSA

func VerifySHA256WithRSA(signed string, source string, publicKey *rsa.PublicKey) error

VerifySHA256WithRSA 使用公钥对字符以 SHA256WithRSA 算法验证签名

func VerifySha256WithRSAUseURLValues

func VerifySha256WithRSAUseURLValues(param url.Values, publicKey *rsa.PublicKey) error

VerifySha256WithRSAUseURLValues 通过公钥对 url.Values 以 Sha256WithRSA 算法

Types

This section is empty.

Jump to

Keyboard shortcuts

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