From fb653292612eddca5b088ed88466c546d1597107 Mon Sep 17 00:00:00 2001 From: Elizabeth Alexander Hunt Date: Sat, 20 Jun 2026 09:40:07 -0700 Subject: Initial commit --- utils/random_id.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 utils/random_id.go (limited to 'utils/random_id.go') diff --git a/utils/random_id.go b/utils/random_id.go new file mode 100644 index 0000000..e6dc731 --- /dev/null +++ b/utils/random_id.go @@ -0,0 +1,15 @@ +package utils + +import ( + "crypto/rand" + "fmt" +) + +// RandomId returns a 128-bit hex id, handy for sessions, db rows, etc. +func RandomId() string { + id := make([]byte, 16) + if _, err := rand.Read(id); err != nil { + panic(err) + } + return fmt.Sprintf("%x", id) +} -- cgit v1.3