Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToString(b []byte) string
- func StringToBytes(s string) (b []byte)
- type Tokenizer
- func (t *Tokenizer) Generate(id uint64, expireAt time.Time, addt, mask uint16) (string, error)
- func (t *Tokenizer) Refresh(token string, expireAt time.Time, validAfter time.Duration, mask uint16, ...) (string, error)
- func (t *Tokenizer) Validate(token string, mask uint16, checks ...func(uint16) error) (uint64, uint16, time.Time, error)
Constants ¶
View Source
const (
TokenLength = 88
)
Variables ¶
View Source
var ( ErrInvalidTokenKeySize = errors.New("invalid token key size") ErrExpiredToken = errors.New("expired token") ErrInvalidToken = errors.New("invalid token") ErrInvalidTokenLength = errors.New("invalid token len") )
View Source
var (
ErrCipherTextTooShort = errors.New("ciphertext too short")
)
Functions ¶
Types ¶
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
Tokenizer xchacha20 对称加密密钥
func (*Tokenizer) Generate ¶
Generate 生成 token
- id 用户标识符, 被加密
- expireAt 有效期至
- addt, mask 附加数据和其掩码, 不被加密
Click to show internal directories.
Click to hide internal directories.