Skip to content

Instantly share code, notes, and snippets.

@brendan-rius
Created October 19, 2025 23:46
Show Gist options
  • Select an option

  • Save brendan-rius/af3877b9ec2a3df0fef36a120875ce2b to your computer and use it in GitHub Desktop.

Select an option

Save brendan-rius/af3877b9ec2a3df0fef36a120875ce2b to your computer and use it in GitHub Desktop.
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