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

Function hashWithSaltAndIter

coderd/userpassword/userpassword.go:125–136  ·  view source on GitHub ↗

Produces a string representation of the hash.

(password string, salt []byte, iter int)

Source from the content-addressed store, hash-verified

123
124// Produces a string representation of the hash.
125func hashWithSaltAndIter(password string, salt []byte, iter int) string {
126 var (
127 hash = pbkdf2.Key([]byte(password), salt, iter, hashLength, sha256.New)
128 encHash = make([]byte, base64Encoding.EncodedLen(len(hash)))
129 encSalt = make([]byte, base64Encoding.EncodedLen(len(salt)))
130 )
131
132 base64Encoding.Encode(encHash, hash)
133 base64Encoding.Encode(encSalt, salt)
134
135 return fmt.Sprintf("$%s$%d$%s$%s", hashScheme, iter, encSalt, encHash)
136}
137
138// Validate checks that the plain text password meets the minimum password requirements.
139// It returns properly formatted errors for detailed form validation on the client.

Callers 2

CompareFunction · 0.85
HashFunction · 0.85

Calls 1

EncodeMethod · 0.80

Tested by

no test coverage detected