chore: add recommendations to documentation of hash functions.
This commit is contained in:
		
							parent
							
								
									60ce81e5fe
								
							
						
					
					
						commit
						a4bb55f56a
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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"},
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user