Documentation
¶
Overview ¶
Package crypto provides password hashing and comparison using bcrypt (golang.org/x/crypto/bcrypt).
Role in architecture:
- Infrastructure utility: no business logic; used by auth or user flows that need to hash/compare passwords.
Responsibilities:
- HashAndSalt: hash a plain password with bcrypt.MinCost; log and return empty string on error.
- ComparePassword: return true if plain password matches the hash; log on error.
Constraints:
- Single cost (MinCost); no configurable cost or salt in this package.
- Depends on logger for error logging.
This package must NOT:
- Store or retrieve passwords; only hash and compare.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePassword ¶
ComparePassword returns true if plainPassword matches hashedPassword; logs and returns false on error. Returns false without calling bcrypt if hashedPassword is empty or too short to be a valid bcrypt hash, avoiding error logs for missing or invalid stored hashes.
func HashAndSalt ¶
HashAndSalt hashes plainPassword with bcrypt (MinCost) and returns the hash string. On bcrypt error logs and returns "".
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.