sign

package
v0.0.0-...-7a729f8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FROM_CONFIG = iota
	FROM_AUTHOR
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Sign

type Sign struct {
	Key       string //签名KEY
	KeyName   string //key名称,默认 AppKey
	AppId     string //应用id
	AppIdName string //应用id名称,默认AppId,Server侧的规则是AppID
	IsSign    bool   //是否需要签名验证
	Type      int    //0表示 Key和IsSign从配置文件读取,1表示调用者赋值
	IsToLower bool   //签名原字符串是否全部转化成小写字符
}

func New

func New() *Sign

实例化单例

func NewInst

func NewInst(index int) *Sign

新对象,避免覆盖

func (*Sign) GenSign

func (s *Sign) GenSign(params interface{}) string

获取签名sgin

func (*Sign) SetAppId

func (s *Sign) SetAppId(appId string) *Sign

设置AppId值

func (*Sign) SetAppIdName

func (s *Sign) SetAppIdName(name string) *Sign

设置签名Appid的 name

func (*Sign) SetIsSgin

func (s *Sign) SetIsSgin(isSign bool) *Sign

设置是否需要签名

func (*Sign) SetKey

func (s *Sign) SetKey(key string) *Sign

设置KEY值

func (*Sign) SetKeyName

func (s *Sign) SetKeyName(name string) *Sign

设置签名key的key name

func (*Sign) SetType

func (s *Sign) SetType(_type int) *Sign

设置是否从配置文件读取检验KEY(0表示从配置文件读取参数)

func (*Sign) ToLower

func (s *Sign) ToLower(lower bool) *Sign

设置签名原字符串是否需要全部转换成小写字符

func (*Sign) VerifyMapSign

func (s *Sign) VerifyMapSign(sign string, signmap map[string]string) bool

和server保持一致的签名方案 body + appId+appkey + timestamp

func (*Sign) VerifyParamsSign

func (s *Sign) VerifyParamsSign(params interface{}) bool

实施签名验证

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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