Created
October 19, 2025 23:46
-
-
Save brendan-rius/af3877b9ec2a3df0fef36a120875ce2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/base32" | |
| "encoding/binary" | |
| "fmt" | |
| ) | |
| func HashChatId(v uint64) string { | |
| var b [8]byte | |
| binary.LittleEndian.PutUint64(b[:], v) | |
| s := base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(b[:]) | |
| // cap at 20 chars | |
| if len(s) > 20 { | |
| return s[:20] | |
| } | |
| return s | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment