rsa

package
v0.0.0-...-7553a0f Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64PublicKeyToRSA

func Base64PublicKeyToRSA(base64PublicKey string) (*rsa.PublicKey, error)

func Base64ToPrivateKey

func Base64ToPrivateKey(base64EncodedKey string) (*rsa.PrivateKey, error)

func Base64ToPrivateKeyByPkcs8

func Base64ToPrivateKeyByPkcs8(base64EncodedKey string) (*rsa.PrivateKey, error)

func HmacSha256ToBase64

func HmacSha256ToBase64(key string, data string) string

func PKCS5Padding

func PKCS5Padding(data []byte, blockSize int) []byte

PKCS5Padding 对数据进行PKCS5填充

func PKCS5Unpadding

func PKCS5Unpadding(data []byte) ([]byte, error)

PKCS5Unpadding 去除PKCS5填充

func PrivateKeyPkcs8ToBytes

func PrivateKeyPkcs8ToBytes(privateKey *rsa.PrivateKey) []byte

func PrivateKeyToBytes

func PrivateKeyToBytes(privateKey *rsa.PrivateKey) []byte

func PublicKeyToBytes

func PublicKeyToBytes(publicKey *rsa.PublicKey) []byte

func RSADecrypt

func RSADecrypt(ciphertext string, privateKey *rsa.PrivateKey) ([]byte, error)

RSADecrypt 使用 RSA 私钥对数据进行解密

func RSAEncrypt

func RSAEncrypt(data map[string]interface{}, publicKey *rsa.PublicKey) (string, error)

RSAEncrypt 使用 RSA 公钥对数据进行加密

func RSASign

func RSASign(data map[string]interface{}, privateKey *rsa.PrivateKey) (string, error)

RSASign 使用 RSA 私钥对数据进行签名

func RSASignByString

func RSASignByString(data string, privateKey *rsa.PrivateKey) (string, error)

func RSAVerify

func RSAVerify(data map[string]interface{}, publicKey *rsa.PublicKey) error

RSAVerify 验证 RSA 签名的有效性

func RSAVerifyByString

func RSAVerifyByString(data string, signature string, publicKey *rsa.PublicKey) error

RSAVerify 验证 RSA 签名的有效性

func SortParam

func SortParam(param map[string]interface{}, appendFilename bool) string

func ZeroPadding

func ZeroPadding(data []byte, blockSize int) []byte

ZeroPadding 使用ZeroPadding填充数据

func ZeroUnpadding

func ZeroUnpadding(data []byte) ([]byte, error)

ZeroUnpadding 去除ZeroPadding填充数据

Types

type SignAlgo

type SignAlgo struct{}

func (*SignAlgo) Sign

func (s *SignAlgo) Sign(data map[string]interface{}, secret []byte) string

func (*SignAlgo) Verify

func (s *SignAlgo) Verify(data map[string]interface{}, secret []byte) bool

Jump to

Keyboard shortcuts

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