Documentation ¶
Index ¶
- Variables
- func AesCbcDecrypt(key, cipherText string) ([]byte, error)
- func AesCbcEncrypt(key string, rawText []byte) (string, error)
- func ConcatArray(v any) string
- func ConcatMap(mp map[string]any, hasBrace bool) string
- func ConcatMapWithSort(mp map[string]string, sep1, sep2 string) string
- func HexSha1(str string) string
- func HexSha256(str string) string
- func HexSha512(str string) string
- func Hmac512(key, str string) string
- func HmacSha1(key, str string) string
- func HmacSha256(key, str string) string
- func Iat() string
- func IatSign(s string) (iat, sign string)
- func IatSignWith(s string, hash func(iat, s string) string) (iat, sign string)
- func PCKSPadding(origData []byte, blockSize int) []byte
- func PCKSUnPadding(origData []byte, blockSize int) ([]byte, error)
- func RsaDecrypt(pri *rsa.PrivateKey, ciphertext string) (string, error)
- func RsaEncrypt(pub *rsa.PublicKey, rawText string) (string, error)
- func Sign(mp map[string]any, secret string, sign func(string) string) string
- func VerifyIat(iat string, availWindow time.Duration) bool
- func VerifyIatSign(iat, targetSign, s string, iatTimout time.Duration) bool
- func VerifyIatSignWith(iat, targetSign, s string, availWindow time.Duration, ...) bool
- type H
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 ¶
AesCbcDecrypt aes cbc, base64 decoded iv + ciphertext. key must 16, 24, 32
func AesCbcEncrypt ¶
AesCbcEncrypt aes cbc, iv + ciphertext with base64 encoded. key must one of 16, 24, 32
func ConcatMap ¶
ConcatMap 拼接对象,按key排序, 忽略空值. hasBrace 前后是否带有大括号 格式: hasBrace=false, k1=v1&k2=v2 格式: hasBrace=true, {k1=v1&k2=v2}
func ConcatMapWithSort ¶
ConcatMapWithSort 拼接对象, 按key排序, 忽略空值. 格式: k1=v1&k2=v2 (其中sep1='=', sep2='&')
func HmacSha256 ¶
HmacSha256 hmac sha256 with base64 encoded.
func IatSignWith ¶
IatSignWith 签发获取签发时间和签名
func PCKSPadding ¶
PCKSPadding PKCS#5和PKCS#7 填充
func PCKSUnPadding ¶
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 ¶
RsaEncrypt rsa PKCS #1 v1.5. and base64 encoded.
func VerifyIatSign ¶
VerifyIatSign 验证签发时间是否在有效期内, 并验证签名是否正确
Types ¶
Click to show internal directories.
Click to hide internal directories.