token

package
v0.0.0-...-5dfeaac Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 14 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

func Sign

func Sign(id uint, username string) (string, error)

签名

Types

type LoginToken

type LoginToken struct {
	jwt.Payload
	ID       uint   `json:"id"`
	Username string `json:"username"`
}

记录登录信息的 JWT

func Verify

func Verify(token []byte) (*LoginToken, error)

验证

Jump to

Keyboard shortcuts

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