token

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: MIT Imports: 9 Imported by: 0

README

与 UrlSign 对应的 PHP 加密算法

// 对 params key 进行排序
ksort($params);

// 对 sortParams 进行 Encode
$sortParamsEncode = http_build_query($params);

// 加密字符串规则 path + method + sortParamsEncode + secret
$encryptStr = $path . $method . $sortParamsEncode . $secret

// 对加密字符串进行 md5
$md5Str = md5($encryptStr);

// 对 md5Str 进行 base64 encode
$tokenString = base64_encode($md5Str);

echo $tokenString;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Token

type Token interface {

	// JWT 签名方式
	JwtSign(userId int64, userName string, expireDuration time.Duration) (tokenString string, err error)
	JwtParse(tokenString string) (*claims, error)

	// URL 签名方式,不支持解密
	UrlSign(path string, method string, params url.Values) (tokenString string, err error)
	// contains filtered or unexported methods
}

func New

func New(secret string) Token

Jump to

Keyboard shortcuts

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