Documentation ¶
Overview ¶
hashpassword.go wraps the bcrypt password hashing library with base64 encoding so we can deal in strings
bcrypt is based on this paper: https://www.usenix.org/legacy/event/usenix99/provos/provos.pdf
Index ¶
- func ChooseOne(prompt string, values ...string) string
- func CoalesceStrings(strs ...string) string
- func ComparePassword(hashBase64, testPassword string) bool
- func CompareStrings(s1, s2 string) int
- func ContainsString(slice []string, value string) bool
- func HashCost(hashBase64 string) (int, error)
- func HashPassword(password string, cost int) (string, error)
- func HashPasswordDefaultCost(password string) (string, error)
- func InStrings(str string, strs ...string) bool
- func Prompt(prompt string) string
- func PromptPassword(prompt string) string
- func PromptYesNo(prompt string, yesIsDefault bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseOne ¶
ChooseOne prompts the user to enter one of n values Example: answer := misc.PromptOne("Continue, Quit, or Redo? [cqr]: ", ["c", "q", "r"])
func CoalesceStrings ¶
ColesceStrings returns the first non-empty string value or, if none qualify, it returns an empty string
func ComparePassword ¶
ComparePassword hashes the test password and then compares the two hashes.
func CompareStrings ¶
CompareStrings returns negative when first string is less, positive if more, zero otherwise
func ContainsString ¶
ContainsString returns true if the given slice contains the given string
func HashPassword ¶
HashPassword hashes the clear-text password and encodes it as base64,
func HashPasswordDefaultCost ¶
HashPasswordDefaultCost hashes the clear-text password and encodes it as base64,
func InStrings ¶
InStrings returns true if the first argument is in the list of following arguments or it returns false if none match. InStrings is similar to ConstainsString which takes a slice of strings instead of a variable number of string arguments.
func PromptPassword ¶
PromptPassword prompts user for a password that is never echoed back to the screen. This needs to be improved because it leaves terminal in unusable state when user presses Ctrl-C
func PromptYesNo ¶
PromptYesNo returns true if user answered something that starts with "y". PromptYesNo returns false if user answers something that starts with "n". PromptYesNo returns yesIsDefault if no answer given.
Types ¶
This section is empty.