feature: verify tokens

This commit is contained in:
2024-11-17 22:28:29 +05:30
parent 26a00c9f7c
commit 9d40c9d7ec
57 changed files with 4188 additions and 276 deletions

29
util/uid/sqid.go Normal file
View File

@@ -0,0 +1,29 @@
package uid
import "github.com/sqids/sqids-go"
// use your own random version of alphabets
// there is online util at the bottomt of this page: https://sqids.org/go
var opts sqids.Options = sqids.Options{
Alphabet: "fsvjrnGWiTk2Lt1l5MzEhFH73CIg60ByexQPYpX9Ro8ZKawAVUdNuDJbmqScO4",
}
// Encode a slice of IDs into one unique ID
func Encode(ids []uint64) (string, error) {
s, err := sqids.New()
if err != nil {
return "", err
}
return s.Encode(ids) // "86Rf07"
}
// Decode an ID back to slice of IDs
func Decode(id string) ([]uint64, error) {
s, err := sqids.New()
if err != nil {
return nil, err
}
return s.Decode(id), nil
}