carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package wireid
2
3import (
4 "encoding/base64"
5 "encoding/hex"
6)
7
8func ValidID(s string) bool {
9 if len(s) != 43 {
10 return false
11 }
12 b, e := base64.RawURLEncoding.Strict().DecodeString(s)
13 return e == nil && len(b) == 32 && base64.RawURLEncoding.EncodeToString(b) == s
14}
15func ValidDigest(s string) bool {
16 if len(s) != 64 {
17 return false
18 }
19 b, e := hex.DecodeString(s)
20 return e == nil && len(b) == 32 && hex.EncodeToString(b) == s
21}
22