salt
This commit is contained in:
parent
8f5b4b921a
commit
b06246c2d8
4
main.go
4
main.go
|
@ -187,12 +187,12 @@ func createPasswordEntry(email, password string) string {
|
|||
c.Write([]byte(password))
|
||||
// hash := c.Sum(nil)
|
||||
salt := base64.StdEncoding.EncodeToString(getSalt())
|
||||
str := base64.StdEncoding.EncodeToString([]byte(string(c.Sum(nil))))
|
||||
str := base64.StdEncoding.EncodeToString([]byte(string(c.Sum(nil)) + string(salt)))
|
||||
return fmt.Sprintf("%s|{SHA512-CRYPT}$6$%s$%s", email, salt, str)
|
||||
}
|
||||
|
||||
func getSalt() []byte {
|
||||
salt := make([]byte, 5)
|
||||
salt := make([]byte, 10)
|
||||
_, err := io.ReadFull(rand.Reader, salt)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue