salt

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

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

func IsValidSalt(s string) (bool, error)

IsValidSalt returns a boolean value indicating whether 's' can be used a salt.

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.

func NewRandomSalt

func NewRandomSalt(opts *SaltOptions) (*Salt, error)

NewRandomSalt return a new `Salt` instance for a random string configured by 'opts'.

func NewSaltFromString

func NewSaltFromString(s string) (*Salt, error)

NewSaltFromString returns a new `Salt` instance derived from 's'.

func (*Salt) Bytes

func (s *Salt) Bytes() []byte

String returns the byte value of 's'.

func (*Salt) String

func (s *Salt) String() string

String returns the string value of '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 no limits or restrictions save a minimum length of 32 bytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL