xsign

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package xsign 提供两类签名, 都不是加密, 也不能替换 xcrypto.Encrypt / Seal.

GenSign 是 pkg 通用 ts+key MD5; MSGenSign 是微服务拼串 MD5.

Index

Constants

View Source
const SignFieldName = "sign"

Variables

This section is empty.

Functions

func GenSign

func GenSign(ts int64, key string) string

GenSign 使用时间戳和密钥生成简单签名字符串 算法: md5(ts+key) 结果: ts+sign

func GenSignNow

func GenSignNow(key string) (int64, string)

GenSignNow 以 NTP 校正后的当前时间戳生成签名.

func GenSignString

func GenSignString(ts, key string) string

GenSignString 字符串类型的时间戳生成签名

func MSGenSign

func MSGenSign(params any, token string) (raw, sign string)

MSGenSign 算法: 拼串后 MD5 md5(k1=v1&k2=v2&token) Ref: microservice/common

func MSGenSignWithRaw

func MSGenSignWithRaw(raw, token string) string

func MSGetSignRaw

func MSGetSignRaw(params any) (raw, sign string)

MSGetSignRaw 拼接参数为待加密的字符串, 如: k1=v1&k2=v2& 如果参数中包含 `sign` 字段会填充到第二个返回值

func MSVerifySign

func MSVerifySign(params any, token string) (raw string, match bool)

MSVerifySign 用参数中的 `sign` 字段值校验由此参数生成的签名

func VerifySign

func VerifySign(key, sign string) bool

VerifySign 校验签名

func VerifySignTTL

func VerifySignTTL(key, sign string, second int64) bool

VerifySignTTL 校验签名及签名有效期(当前时间 **秒 范围内有效)

func VerifySignTTLAt

func VerifySignTTLAt(key, sign string, second, now int64) bool

VerifySignTTLAt 按给定 Unix 秒校验签名有效期, 供测试注入时钟.

Types

This section is empty.

Jump to

Keyboard shortcuts

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