secure

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: Apache-2.0 Imports: 5 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 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.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service holds security related methods.

func New

func New(h hash.Hash) *Service

New initializes security service.

func (Service) Hash

func (s Service) Hash(b []byte) string

Hash hashes a stream of bytes using sha2 algorihtm.

func (Service) HashMatchesPassword

func (Service) HashMatchesPassword(hash, password string) bool

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

func (Service) HashPW

func (Service) HashPW(password string) string

HashPW hashes the password using bcrypt.

func (Service) Token

func (Service) Token(str string) string

Token generates new unique token.

Jump to

Keyboard shortcuts

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