Documentation
¶
Overview ¶
Package bcryptio provides minimal wrappers around the bcrypt package to allow for command-line operations such as comparing passwords, checking costs, generating hashes, and generating random passwords with their hashes.
Index ¶
Constants ¶
const (
// DefaultLength is the default length of the a password.
DefaultLength = 20
)
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare reads a previously hashed password from the input reader and a plain text password, then compares them using bcrypt.
If the plain text password matches the hashed password, it prints a success message; otherwise, it returns an error.
func Cost ¶
Cost reads a previously hashed password from the input reader and prints the cost used to create that hash.
If the hash is invalid, an error is returned.
func Generate ¶
Generate creates a random password of the specified length, hashes it using bcrypt with the specified cost, and writes both the plaintext password and the hashed password to the output writer.
If symbols is true, the password will include symbols; otherwise, it will only include alphanumeric characters.
If the length is less than DefaultLength, it will be set to DefaultLength.
If the length exceeds maxLength, it will be set to maxLength.
The cost parameter determines the computational cost of hashing the password.
If an error occurs during password generation or hashing, it will be returned.
Types ¶
This section is empty.