1package mox
2
3import (
4 cryptorand "crypto/rand"
5)
6
7func GeneratePassword() string {
8 chars := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*-_;:,<.>/"
9 s := ""
10 buf := make([]byte, 1)
11 for i := 0; i < 12; i++ {
12 for {
13 cryptorand.Read(buf)
14 i := int(buf[0])
15 if i+len(chars) > 255 {
16 continue // Prevent bias.
17 }
18 s += string(chars[i%len(chars)])
19 break
20 }
21 }
22 return s
23}
24