diff --git a/README.md b/README.md index b38c4e2..e544c97 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/passwd_test.go b/passwd_test.go index 19b5645..e786b83 100644 --- a/passwd_test.go +++ b/passwd_test.go @@ -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" diff --git a/pkg/unix/unix_test.go b/pkg/unix/unix_test.go index 0dacec0..c36642d 100644 --- a/pkg/unix/unix_test.go +++ b/pkg/unix/unix_test.go @@ -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"},