Sort by: Newest, Oldest, Most Relevant
(#6ov54wa) > Hold up now, that example hash doesn't have a `$` prefix! Well for this there is the option for a hash type to set itself as a fall through if a matching hash doesn't exist. This is good for legacy password types that don't follow the convention. ``` func (p *plainPasswd) ApplyPasswd(passwd *passwd.Passwd) { passwd.Register("plain", p) passwd.SetFallthrough(p) } ```

matched #252vgia score:11.94 Search by:
Search by 1 tags:
(#6ov54wa) Circling back to the IsPreferred method. A hasher can define its own IsPreferred method that will be called to check if the current hash meets the complexity requirements. This is good for updating the password hashes to be more secure over time. ``` func (p *Passwd) IsPreferred(hash string) bool { _, algo := p.getAlgo(hash) if algo != nil && algo == p.d { // if the algorithm defines its own check for preference. if ck, ok := algo.(interface{ IsPreferred(string) bool }); ok { return ck.IsPreferred(hash) } return true } return false } ``` example:

matched #5c7ps5q score:11.94 Search by:
Search by 1 tags:
(#6ov54wa) Here is an example of usage: ``` func Example() { pass := "my_pass" hash := "my_pass" pwd := passwd.New( &unix.MD5{}, // first is preferred type. &plainPasswd{}, ) _, err := pwd.Passwd(pass, hash) if err != nil { fmt.Println("fail: ", err) } // Check if we want to update. if !pwd.IsPreferred(hash) { newHash, err := pwd.Passwd(pass, "") if err != nil { fmt.Println("fail: ", err) } fmt.Println("new hash:", newHash) } // Output: // new hash: $1$81ed91e1131a3a5a50d8a68e8ef85fa0 } ``` This shows how one would set a preferred hashing type and if the current version of ones password is not the preferred type updates it to enhance the security of the hashed password when someone logs in.

matched #ssaasaa score:11.94 Search by:
Search by 1 tags:
(#6ov54wa) > Hold up now, that example hash doesn't have a `$` prefix! Well for this there is the option for a hash type to set itself as a fall through if a matching hash doesn't exist. This is good for legacy password types that don't follow the convention. ``` func (p *plainPasswd) ApplyPasswd(passwd *passwd.Passwd) { passwd.Register("plain", p) passwd.SetFallthrough(p) } ```

matched #vbh7m6a score:11.94 Search by:
Search by 1 tags:
(#6ov54wa) Here is an example of usage: ``` func Example() { pass := "my_pass" hash := "my_pass" pwd := passwd.New( &unix.MD5{}, // first is preferred type. &plainPasswd{}, ) _, err := pwd.Passwd(pass, hash) if err != nil { fmt.Println("fail: ", err) } // Check if we want to update. if !pwd.IsPreferred(hash) { newHash, err := pwd.Passwd(pass, "") if err != nil { fmt.Println("fail: ", err) } fmt.Println("new hash:", newHash) } // Output: // new hash: $1$81ed91e1131a3a5a50d8a68e8ef85fa0 } ``` This shows how one would set a preferred hashing type and if the current version of ones password is not the preferred type updates it to enhance the security of the hashed password when someone logs in.

matched #y6z6zca score:11.94 Search by:
Search by 1 tags:
(#6ov54wa) Circling back to the IsPreferred method. A hasher can define its own IsPreferred method that will be called to check if the current hash meets the complexity requirements. This is good for updating the password hashes to be more secure over time. ``` func (p *Passwd) IsPreferred(hash string) bool { _, algo := p.getAlgo(hash) if algo != nil && algo == p.d { // if the algorithm defines its own check for preference. if ck, ok := algo.(interface{ IsPreferred(string) bool }); ok { return ck.IsPreferred(hash) } return true } return false } ``` example:

matched #zh5caoa score:11.94 Search by:
Search by 1 tags:
This is twtxt search engine and crawler. Please contact Support if you have any questions, concerns or feedback!