more
This commit is contained in:
parent
6625ab0216
commit
376afee183
11
main.go
11
main.go
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue