MCPcopy Index your code
hub / github.com/coder/coder / Hash

Function Hash

coderd/userpassword/userpassword.go:114–122  ·  view source on GitHub ↗

Hash generates a hash using pbkdf2. See the Compare() comment for rationale.

(password string)

Source from the content-addressed store, hash-verified

112// Hash generates a hash using pbkdf2.
113// See the Compare() comment for rationale.
114func Hash(password string) (string, error) {
115 salt := make([]byte, defaultSaltSize)
116 _, err := rand.Read(salt)
117 if err != nil {
118 return "", xerrors.Errorf("read random bytes for salt: %w", err)
119 }
120
121 return hashWithSaltAndIter(password, salt, defaultHashIter), nil
122}
123
124// Produces a string representation of the hash.
125func hashWithSaltAndIter(password string, salt []byte, iter int) string {

Callers 11

putUserPasswordMethod · 0.92
CreateUserMethod · 0.92
UsersFilterFunction · 0.92
TestUserPasswordCompareFunction · 0.92
resetPasswordMethod · 0.92
userpassword.goFile · 0.85

Calls 3

hashWithSaltAndIterFunction · 0.85
ReadMethod · 0.65
ErrorfMethod · 0.45