util

package
v0.0.0-...-9c09179 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExpireTime = time.Hour * 24 * 7

ExpireTime ...

View Source
var (
	RandomString = map[RandomKind]string{
		RandomNum:      "0123456789",
		RandomLower:    "abcdefghijklmnopqrstuvwxyz",
		RandomUpper:    "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
		RandomLowerNum: "0123456789abcdefghijklmnopqrstuvwxyz",
		RandomUpperNum: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
		RandomAll:      "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
	}
)

RandomString defines

Functions

func DecryptJWT

func DecryptJWT(key []byte, token string) (string, error)

DecryptJWT ...

func EncryptJWT

func EncryptJWT(key []byte, sub []byte, expiry ...time.Duration) (string, error)

EncryptJWT ...

func GenSpreadSign

func GenSpreadSign() string

GenSpreadSign ...

func GenerateRandomString

func GenerateRandomString(size int, kind ...RandomKind) string

GenerateRandomString 随机字符串

func GenerateRandomString2

func GenerateRandomString2(size int, kind int) []byte

GenerateRandomString2 随机字符串

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

MarshalJSON ...

func SHA256

func SHA256(v, key, salt string) string

SHA256 ...

func StructureName

func StructureName(s interface{}) string

StructureName ...

func ToToken

func ToToken(key string, token *WebToken) (string, error)

ToToken ...

func UnmarshalJSON

func UnmarshalJSON(reader io.Reader, v interface{}) error

UnmarshalJSON ...

Types

type RandomKind

type RandomKind int

RandomKind RandomKind

const (
	RandomNum      RandomKind = iota // 纯数字
	RandomLower                      // 小写字母
	RandomUpper                      // 大写字母
	RandomLowerNum                   // 数字、小写字母
	RandomUpperNum                   // 数字、大写字母
	RandomAll                        // 数字、大小写字母
)

random kinds

type WebToken

type WebToken struct {
	UID      string `json:"oid"`
	Nickname string `json:"nickname"`
}

WebToken ...

func FromToken

func FromToken(key, token string) (*WebToken, error)

FromToken ...

func NewWebToken

func NewWebToken(id, name string) *WebToken

NewWebToken ...

Jump to

Keyboard shortcuts

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