gorsa

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 密钥长度
	KEYSIZE = 1024
)

Variables

This section is empty.

Functions

func DecryptByPrivateKey

func DecryptByPrivateKey(data []byte, privateKeyStr string) ([]byte, error)

DecryptByPrivateKey 使用私钥解密 - 使用PKCS1v15填充,与Java的RSA/ECB/PKCS1Padding转换模式兼容

func EncryptByPrivateKey

func EncryptByPrivateKey(data []byte, privateKeyStr string) ([]byte, error)

EncryptByPrivateKey 使用私钥加密(签名)- 使用PKCS1v15填充,与Java的RSA/ECB/PKCS1Padding转换模式兼容

func EncryptByPublicKey

func EncryptByPublicKey(data []byte, publicKeyStr string) ([]byte, error)

EncryptByPublicKey 使用公钥加密 - 使用PKCS1v15填充,与Java的RSA/ECB/PKCS1Padding转换模式兼容

func GenerateKey

func GenerateKey() ([]string, error)

GenerateKey 生成RSA公私钥对

func LoadPrivateKeyFromFile

func LoadPrivateKeyFromFile(filename string) (string, error)

LoadPrivateKeyFromFile 从文件加载私钥

func LoadPublicKeyFromFile

func LoadPublicKeyFromFile(filename string) (string, error)

LoadPublicKeyFromFile 从文件加载公钥

func SaveKeyToPemFile

func SaveKeyToPemFile(publicKeyBase64, privateKeyBase64, publicKeyFile, privateKeyFile string) error

SaveKeyToPemFile 将公钥和私钥保存到PEM文件

func Sign

func Sign(data []byte, privateKeyStr string) (string, error)

Sign 签名数据 - 使用SHA1和PKCS1v15填充,与Java的SHA1WithRSA签名算法兼容

func Verify

func Verify(data []byte, publicKeyStr string, sign string) (bool, error)

Verify 验证签名 - 使用SHA1和PKCS1v15填充,与Java的SHA1WithRSA签名算法兼容

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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