mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 23:19:37 +00:00
16 lines
296 B
Go
16 lines
296 B
Go
package utils
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base32"
|
|
)
|
|
|
|
func GeneratePickupCode() string {
|
|
bytes := make([]byte, 4)
|
|
if _, err := rand.Read(bytes); err != nil {
|
|
panic(err)
|
|
}
|
|
encoding := base32.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")
|
|
return encoding.EncodeToString(bytes)[:4]
|
|
}
|