diff --git a/main.go b/main.go index c9828ef..8857729 100644 --- a/main.go +++ b/main.go @@ -186,16 +186,16 @@ func createPasswordEntry(email, password string) string { c := crypto.SHA512.New() c.Write([]byte(password)) // hash := c.Sum(nil) - salt := getSalt() - str := base64.StdEncoding.EncodeToString([]byte(string(c.Sum(nil)) + salt)) - return fmt.Sprintf("%s|{SHA512-CRYPT}$6$%s", email, str) + salt := base64.StdEncoding.EncodeToString(getSalt()) + str := base64.StdEncoding.EncodeToString([]byte(string(c.Sum(nil)))) + return fmt.Sprintf("%s|{SHA512-CRYPT}$6$%s$%s", email, salt, str) } -func getSalt() string { +func getSalt() []byte { salt := make([]byte, 5) _, err := io.ReadFull(rand.Reader, salt) if err != nil { log.Fatal(err) } - return string(salt) + return salt }