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

13
main.go
View File

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