utils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(value, min, max int64) int64

Clamp clamps the given value to the given range.

func ClampCookieAge added in v0.7.2

func ClampCookieAge(seconds *int64) int64

ClampCookieAge returns a valid cookie age in seconds.

func DirSize added in v0.7.0

func DirSize(dirPath string) (int64, error)

func ExtractPDF added in v0.7.0

func ExtractPDF()

func FileSize added in v0.7.0

func FileSize(filePath string) (int64, error)

func IsValidPassword added in v0.7.2

func IsValidPassword(password string) bool

IsValidPassword checks if the password is valid.

func IsValidSessionName added in v0.7.2

func IsValidSessionName(sessionName *string) bool

IsValidSessionName checks if the session name is valid.

func IsValidUsername added in v0.7.2

func IsValidUsername(username string) bool

IsValidUsername checks if the username is valid.

func PathExists added in v0.7.0

func PathExists(pathTo string) bool

PathExists checks if the given path exists.

func PeriodicTask

func PeriodicTask(d time.Duration, f func())

PeriodicTask loops the given function in separate thread between the given interval.

func ReadJSON added in v0.7.0

func ReadJSON(jsonFile string) ([]byte, error)

ReadJSON returns the given JSON file as bytes.

func Similarity added in v0.7.0

func Similarity(a string, b string) float64

Similarity calculates the similarity between two strings.

func UniversalExtract added in v0.7.0

func UniversalExtract(dst string, archivePath string) ([]string, int)

UniversalExtract extracts media files from zip, cbz, rar, cbr, tar (all its variants) archives. Plain directories without compression are also supported. For PDF files, use ExtractPDF.

Types

type Argon2idHash added in v0.7.2

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

Argon2idHash is a wrapper for the argon2id hashing algorithm. https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#password-hashing-algorithms

func DefaultArgon2idHash added in v0.7.2

func DefaultArgon2idHash() *Argon2idHash

DefaultArgon2idHash constructor function for Argon2idHash. https://tobtu.com/minimum-password-settings/

func NewArgon2idHash added in v0.7.2

func NewArgon2idHash(time, saltLen, memory uint32, threads uint8, keyLen uint32) *Argon2idHash

NewArgon2idHash constructor function for Argon2idHash.

func (*Argon2idHash) Compare added in v0.7.2

func (a *Argon2idHash) Compare(hash, salt, password []byte) bool

Compare generated hash with stored hash.

func (*Argon2idHash) GenerateHash added in v0.7.2

func (a *Argon2idHash) GenerateHash(password, salt []byte) (*HashSalt, error)

GenerateHash using the password and provided salt. If no salt value was provided, fallbacks to a random value of a given length.

type HashSalt added in v0.7.2

type HashSalt struct {
	Hash []byte
	Salt []byte
}

HashSalt is a wrapper for the hash and salt values.

Jump to

Keyboard shortcuts

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