Produces a string representation of the hash.
(password string, salt []byte, iter int)
| 123 | |
| 124 | // Produces a string representation of the hash. |
| 125 | func 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. |