Documentation
¶
Overview ¶
package salt provides methods for generating string values that can be used as (hashing) salts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidSalt ¶
IsValidSalt returns a boolean value indicating whether 's' can be used a salt. It only checks the length of 's' in bytes, not its entropy; use `NewRandomSalt` to generate salts.
Types ¶
type Salt ¶
type Salt struct {
// contains filtered or unexported fields
}
Salt is a struct containing methods and values that can be used as (hashing) salts. A `Salt` is immutable once created and is safe for concurrent use.
func NewRandomSalt ¶
func NewRandomSalt(opts *SaltOptions) (*Salt, error)
NewRandomSalt return a new `Salt` instance for a random string configured by 'opts'. If 'opts' is nil the result of DefaultSaltOptions is used.
func NewSaltFromString ¶
NewSaltFromString returns a new `Salt` instance derived from 's'.
type SaltOptions ¶
type SaltOptions struct {
// The length of the final salting string.
Length int
// A boolean flag indicating that the salt should only contain ASCII characters.
ASCII bool
}
SaltOptions is a struct containing configuration options for the `NewRandomSalt` method.
func DefaultSaltOptions ¶
func DefaultSaltOptions() *SaltOptions
DefaultOptions returns an `SaltOptions` instance with a minimum length of 32 bytes and ASCII-only characters. Non-ASCII salts are mostly made up of multi-byte characters so they contain far less entropy than an ASCII salt of the same length.