utils

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_ASPECT_RATIO = 1.5
View Source
const DEFAULT_COVER_WIDTH_SHIFT = 0.025
View Source
const DEFAULT_THUMB_COVER_WIDTH = 512
View Source
const DEFAULT_THUMB_PAGE_WIDTH = 256

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 ClampU added in v0.8.1

func ClampU(value, min, max uint64) uint64

ClampU clamps the given unsigned value to the given range.

func ConvertImageToNRGBA added in v0.8.1

func ConvertImageToNRGBA(srcImage image.Image) (*image.NRGBA, error)

func DirSize added in v0.7.0

func DirSize(dirPath string) (int64, error)

func EncodeImage added in v0.8.1

func EncodeImage(dstImage *image.NRGBA) (*bytes.Buffer, error)

EncodeImage encodes the given image to the format specified in the config.

func ExtractPDF added in v0.7.0

func ExtractPDF()

func FileSize added in v0.7.0

func FileSize(filePath string) (int64, error)

func HashStringSHA1 added in v0.8.1

func HashStringSHA1(s string) string

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 TransformImage added in v0.8.1

func TransformImage(srcImage *image.NRGBA, width int, cropLandscape bool, ltr bool) *image.NRGBA

TransformImage resizes the given image to the specified width and returns it. If cover is true, the image will be tried to be cropped to the specified width as some covers include the back cover as well.

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.

type OrderedMap added in v0.8.1

type OrderedMap struct {
	Keys []string
	Map  map[string]interface{}
}

func NewOrderedMap added in v0.8.1

func NewOrderedMap() *OrderedMap

func (*OrderedMap) Get added in v0.8.1

func (om *OrderedMap) Get(key string) (interface{}, bool)

func (*OrderedMap) OrderedKeys added in v0.8.1

func (om *OrderedMap) OrderedKeys() []string

func (*OrderedMap) Set added in v0.8.1

func (om *OrderedMap) Set(key string, value interface{})

Jump to

Keyboard shortcuts

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