This commit is contained in:
scs 2018-12-27 22:32:14 +00:00
parent 6625ab0216
commit 376afee183
1 changed files with 7 additions and 6 deletions

11
main.go
View File

@ -9,6 +9,7 @@ import (
"html/template"
"log"
"crypto/rand"
"encoding/base32"
"net/smtp"
"strings"
)
@ -144,12 +145,12 @@ func RecoverByEmail(e string) {
func randBytes(n int) []byte {
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[rand.Int(len(letterBytes))]
randomBytes := make([]byte, 32)
_, err := rand.Read(randomBytes)
if err != nil {
panic(err)
}
return b
return []byte(base32.StdEncoding.EncodeToString(randomBytes)[:n])
}
func sendRegistrationEmail(recipient, username, password string) bool {