Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareWith ¶
CompareWith reports whether a plain text matches with hash.
For compatibility purposes, it can compare using both SHA256 and bcrypt algorithms. Hashes starting with "$" are assumed to be a bcrypt hash; otherwise, they are treated as SHA256 hashes.
Types ¶
type Hasher ¶
type Hasher interface {
Do(plain string) (string, error) // Hash takes a string and returns its hash.
CompareWith(plain string, hash string) bool // Compare takes a plaintext password and a hashed password, then checks if they match.
}
Hasher hashes passwords and checks them. CompareWith must compare in constant time, so a wrong password cannot be found byte by byte from timing.
var Backend Hasher = &backend{}
Backend is the implementation the package-level helpers use. Tests replace it; production leaves it alone.
Click to show internal directories.
Click to hide internal directories.