token-validator: done many challenges
This commit is contained in:
parent
91edced44d
commit
133244897b
4 changed files with 313 additions and 8 deletions
24
token-validator/token.go
Normal file
24
token-validator/token.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
func GenerateToken(pkey []byte, id int, a... []byte) ([]byte, error) {
|
||||
h, err := blake2b.New(blake2b.Size, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
h.Write(pkey)
|
||||
h.Write([]byte(fmt.Sprintf(":%d", id)))
|
||||
|
||||
for _, v := range a {
|
||||
h.Write([]byte(":"))
|
||||
h.Write(v)
|
||||
}
|
||||
|
||||
return h.Sum(nil), nil
|
||||
}
|
Reference in a new issue