signature

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputInvalidLength     = errors.New("encoded message length must be more than zero")
	ErrInputNotMoreABlock     = errors.New("decoded message length must be more than a block size")
	ErrInputNotMultipleBlocks = errors.New("decoded message length must be multiple of block size")
	ErrInvalidIvSize          = errors.New("iv length must equal block size")
	ErrUnPaddingOutOfRange    = errors.New("unPadding out of range")
)

error defined

Functions

func AesCbcDecrypt

func AesCbcDecrypt(key, cipherText string) ([]byte, error)

AesCbcDecrypt aes cbc, base64 decoded iv + ciphertext. key must 16, 24, 32

func AesCbcEncrypt

func AesCbcEncrypt(key string, rawText []byte) (string, error)

AesCbcEncrypt aes cbc, iv + ciphertext with base64 encoded. key must one of 16, 24, 32

func ConcatArray

func ConcatArray(v any) string

ConcatArray 拼接数组, 不排序, 按","分隔, 忽略空值, 前后带有方括号

func ConcatMap

func ConcatMap(mp map[string]any, hasBrace bool) string

ConcatMap 拼接对象,按key排序, 忽略空值. hasBrace 前后是否带有大括号 格式: hasBrace=false, k1=v1&k2=v2 格式: hasBrace=true, {k1=v1&k2=v2}

func ConcatMapWithSort

func ConcatMapWithSort(mp map[string]string, sep1, sep2 string) string

ConcatMapWithSort 拼接对象, 按key排序, 忽略空值. 格式: k1=v1&k2=v2 (其中sep1='=', sep2='&')

func HexSha1

func HexSha1(str string) string

HexSha1 sha1 with hex encoded.

func HexSha256

func HexSha256(str string) string

HexSha256 sha256 with hex encoded.

func HexSha512

func HexSha512(str string) string

HexSha512 sha512 with hex encoded.

func Hmac512

func Hmac512(key, str string) string

Hmac512 hmac sha1 with base64 encoded.

func HmacSha1

func HmacSha1(key, str string) string

HmacSha1 hmac sha1 with base64 encoded.

func HmacSha256

func HmacSha256(key, str string) string

HmacSha256 hmac sha256 with base64 encoded.

func Iat

func Iat() string

Iat 签发时间字符串

func IatSign

func IatSign(s string) (iat, sign string)

IatSign 签发获取签发时间和签名

func IatSignWith

func IatSignWith(s string, hash func(iat, s string) string) (iat, sign string)

IatSignWith 签发获取签发时间和签名

func PCKSPadding

func PCKSPadding(origData []byte, blockSize int) []byte

PCKSPadding PKCS#5和PKCS#7 填充

func PCKSUnPadding

func PCKSUnPadding(origData []byte, blockSize int) ([]byte, error)

PCKSUnPadding PKCS#5和PKCS#7 解填充

func RsaDecrypt

func RsaDecrypt(pri *rsa.PrivateKey, ciphertext string) (string, error)

RsaDecrypt base64 decoded and rsa PKCS #1 v1.5.

func RsaEncrypt

func RsaEncrypt(pub *rsa.PublicKey, rawText string) (string, error)

RsaEncrypt rsa PKCS #1 v1.5. and base64 encoded.

func Sign

func Sign(mp map[string]any, secret string, sign func(string) string) string

Sign 对象签名

func VerifyIat

func VerifyIat(iat string, availWindow time.Duration) bool

VerifyIat 验证签发时间是否在有效期内

func VerifyIatSign

func VerifyIatSign(iat, targetSign, s string, iatTimout time.Duration) bool

VerifyIatSign 验证签发时间是否在有效期内, 并验证签名是否正确

func VerifyIatSignWith

func VerifyIatSignWith(iat, targetSign, s string, availWindow time.Duration, hash func(iat, s string) string) bool

VerifyIatSignWith 验证签发时间是否在有效期内, 并验证签名是否正确

Types

type H

type H map[string]any

H map[string]any

Jump to

Keyboard shortcuts

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