chore: add recommendations to documentation of hash functions.

This commit is contained in:
Jon Lundy 2022-12-09 10:05:39 -07:00
parent 60ce81e5fe
commit a4bb55f56a
Signed by untrusted user who does not match committer: xuu
GPG Key ID: C63E6D61F3035024
3 changed files with 8 additions and 5 deletions

View File

@ -9,11 +9,11 @@ Here is an example of usage:
```go
func Example() {
pass := "my_pass"
hash := "my_pass"
hash := "$1$81ed91e1131a3a5a50d8a68e8ef85fa0"
pwd := passwd.New(
&unix.MD5{}, // first is preferred type.
&plainPasswd{},
argon2.Argon2id, // first is preferred type.
&unix.MD5{},
)
_, err := pwd.Passwd(pass, hash)
@ -32,7 +32,7 @@ func Example() {
}
// Output:
// new hash: $1$81ed91e1131a3a5a50d8a68e8ef85fa0
// new hash: $argon2id$...
}
```
https://github.com/sour-is/go-passwd/blob/main/passwd_test.go#L33-L59

View File

@ -30,6 +30,9 @@ func (p *plainPasswd) ApplyPasswd(passwd *passwd.Passwd) {
passwd.SetFallthrough(p)
}
// Example of upgrading password hash to a greater complexity.
//
// Note: This example uses very unsecure hash functions to allow for predictable output. Use of argon2.Argon2id or scrypt.Scrypt2 for greater hash security is recommended.
func Example() {
pass := "my_pass"
hash := "my_pass"

View File

@ -14,7 +14,7 @@ func TestPasswdHash(t *testing.T) {
type testCase struct {
pass, hash string
}
tests := []testCase{
{"passwd", "$1$76a2173be6393254e72ffa4d6df1030a"},
{"passwd", "$2a$10$GkJwB.nOaaeAvRGgyl2TI.kruM8e.iIo.OozgdslegpNlC/vIFKRq"},