rsa

package
v0.0.0-...-c3ec36b Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PKCS1 int = iota
	PKCS8
)

Variables

This section is empty.

Functions

func DecodeData

func DecodeData(privateKey []byte, data []byte, pkc ...int) ([]byte, error)

DecodeData 解密

	@param []byte => privateKey 私钥
	@param []byte => data 要解密的数据,如果数据进行过任何编码的请先解码
	@param ...int => pkc 私钥的编码方式 pkcs1 pkcs8
	@return []byte 解密内容
         error 错误信息

func DecodePrivateKey

func DecodePrivateKey(privateKey []byte, pkc ...int) (*rsa.PrivateKey, error)

DecodePrivateKey 解析私钥

func Decrypt

func Decrypt(privateKey []byte, data []byte, pkc ...int) ([]byte, error)

Decrypt RSA解密

func DecryptNoPadding

func DecryptNoPadding(privateKey *rsa.PrivateKey, data []byte) []byte

DecryptNoPadding NO_PADDING模式解密

func EncodeData

func EncodeData(publickey []byte, data []byte, elen ...int) ([]byte, error)

EncodeData 加密,数据如果过长将使用分段加密

	@param []byte => publickey 公钥数据
	@param []byte => data 需要加密的内容
	@param ...int => elen 数据分段加密长度,如果为空将按照密钥的能加密的最大长度分段
	@return []byte 加密结果
         error 错误信息

func Encrypt

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

Encrypt RSA加密

func EncryptNoPadding

func EncryptNoPadding(publickey []byte, data []byte) ([]byte, error)

EncryptNoPadding 无填充模式加密

func GenRsaKey

func GenRsaKey(bits int, pkc ...int) ([]byte, []byte, error)

GenRsaKey 生成RSA密钥 默认使用PKCS1编码 @return privatekey publickey error

func SignSHA1

func SignSHA1(privateKey []byte, data []byte, pkc ...int) ([]byte, error)

SignSHA1 RSA签名 SHA1withRSA

func SignSHA512

func SignSHA512(privateKey []byte, data []byte, pkc ...int) ([]byte, error)

SignSHA512 RSA签名 SHA512withRSA

func VerifySHA1

func VerifySHA1(publickey []byte, data []byte, vStr []byte) (bool, error)

VerifySHA1 RSA验证签名 SHA1withRSA

func VerifySHA512

func VerifySHA512(publickey []byte, data []byte, vStr []byte) (bool, error)

VerifySHA512 RSA验证签名 SHA512withRSA

Types

This section is empty.

Jump to

Keyboard shortcuts

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