secret

package
v0.0.0-...-8cb3723 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue. Example: this will give us a 32 byte output token, err = GenerateRandomString(32)

func GenerateRandomStringURLSafe

func GenerateRandomStringURLSafe(n int) (string, error)

GenerateRandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue. Example: this will give us a 44 byte, base64 encoded output token, err := GenerateRandomStringURLSafe(32)

Types

type Password

type Password struct{}

Password is our secret service implementation

func New

func New() *Password

New returns a password object

func (*Password) HashMatchesPassword

func (p *Password) HashMatchesPassword(hash, password string) bool

HashMatchesPassword matches hash with password. Returns true if hash and password match.

func (*Password) HashPassword

func (p *Password) HashPassword(password string) string

HashPassword hashes the password using bcrypt

func (*Password) HashRandomPassword

func (p *Password) HashRandomPassword() (string, error)

HashRandomPassword creates a random password for passwordless mobile signup

type Service

type Service interface {
	HashPassword(password string) string
	HashMatchesPassword(hash, password string) bool
	HashRandomPassword() (string, error)
}

Service is the interface to our secret service

Jump to

Keyboard shortcuts

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