utils

package
v0.0.0-...-0f828a4 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Argon2IDHashCompare

func Argon2IDHashCompare(s, hash string) (bool, error)

Compares the supplied string with that hash.

func Argon2IDHashString

func Argon2IDHashString(s string, config *Argon2IDConfig) (string, error)

Uses Argon2ID to hash the supplied string with the supplied config. It generates a random salt. Acts as a public-facing wrapper around argon2idHashStringWithSalt.

func CardTextIsValid

func CardTextIsValid(text string) bool

A card is only valid if it has fewer than 101 characters and at least 1 character. If one card of the deck does not follow this rules, the deck won't be valid.

func DeckCardAmountValid

func DeckCardAmountValid(amountWhiteCards, amountBlackCards int) bool

Checks if the card amount for one deck is valid. This is the case if the deck has at most 500 cards in total. Additionally, there have to be at least 5 white and 5 black cards.

func GetBlankCount

func GetBlankCount(text string) int

Returns the amount of blanks found in a text. A blank counts as a blank when it consists of 4 or more underscores (_) that are not separated. The blank ends after the first character that is not an underscore. When no blank was found the blank count is 1. This is because it will likely be a question or something similar.

func MeetsPasswordRequirements

func MeetsPasswordRequirements(password string) bool

Checks if a password meets the password requirements. These are: - At least 8 characters long

Types

type Argon2IDConfig

type Argon2IDConfig struct {
	Time    uint32
	Memory  uint32
	Threads uint8
	KeyLen  uint32
	Format  string
}

func GetDefaultArgon2IDConfig

func GetDefaultArgon2IDConfig() *Argon2IDConfig

Returns the default Argon2ID config used for hashing the password. For more information on why these parameters are used, see the comments of the argon2.IDKey function. At the time of writing this, it was recommended by this draft RFC: https://tools.ietf.org/html/draft-irtf-cfrg-argon2-03#section-9.3

Jump to

Keyboard shortcuts

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