util

package
v0.0.0-...-ded953e Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addcslashes

func Addcslashes(s string) string

TODO use that: regexp.QuoteMeta(`Escaping symbols like: .+*?()|[]{}^$`)

func ExtractDigitsInt

func ExtractDigitsInt(str string) int

func ExtractDigitsString

func ExtractDigitsString(str string) string

func ExtractTitle

func ExtractTitle(str string, limitChars, limitWords int) string

func FileDeletionByMask

func FileDeletionByMask(ctx context.Context, fpathes string) error

func GetDateTimeFromExif

func GetDateTimeFromExif(imageBytes []byte) (string, error)

Parse exif data in image-bytes and get datetime string if exist. If not - get file datetime info. Output photo format is: IMG_20200301_175147.jpg

func GetEmailsAlias

func GetEmailsAlias(email string) string

import("strings")

func GetJwtClaimHMAC

func GetJwtClaimHMAC(tokenString, secret string) ([]byte, map[string]interface{}, error)

func GetMD5Hash

func GetMD5Hash(text string) string

func GetSaltedSha256

func GetSaltedSha256(salt, password string) string

func GetSha256

func GetSha256(text string) string

func GetUserpicURL

func GetUserpicURL(filepath string) string

func ImagefileProgressiveOptimisation

func ImagefileProgressiveOptimisation(ctx context.Context, fpath, targetpath string, removemeta bool) error

Jpeg optimizing with jpegtran utilits then copy to -> userpic and maybe remove origfile

func ImagefileRemove

func ImagefileRemove(fpath string) error

Remove unused file

func ImagefileResizing

func ImagefileResizing(fpath, newfpath string, setwidth uint) error

func ImagefileValidations

func ImagefileValidations(fpath string) error

Validations IsJPG, IsNude

func IsBadWords

func IsBadWords(str string, bads string) bool

func IsEqualSaltedSha256

func IsEqualSaltedSha256(salt, password, hashDatabase string) bool

func JpgValid

func JpgValid(file *os.File) bool

func MakeArgonHash

func MakeArgonHash(password string) (string, error)

func MakeBCryptHash

func MakeBCryptHash(raw string, cost int) string

Generate return a hashed password

func MakeJwtString

func MakeJwtString(secretString, tokid, fqdn, uid, appids, roles string) (string, error)

get real jwt by next params: seckey, tokid, fqdn, uid, appsid, roles

func MakeUploadDirByUserId

func MakeUploadDirByUserId(prevPath, uid string) (string, error)

Make new dir with name as the eid in current prevPath directory For example prevPath="upload/", uid="123" will make new directory "upload/123"

func MatchArgonHashAndPassword

func MatchArgonHashAndPassword(trypass, passhash string) bool

func PhoneNormalisation

func PhoneNormalisation(n string) string

func Pkeyer

func Pkeyer(raw interface{}) int64

func RandToken32bit

func RandToken32bit() string

Google OAUTH clients functions

func RandomHexString

func RandomHexString(n int) string

func RandomUsableString

func RandomUsableString(n int) string

func SendEmailWithTempate

func SendEmailWithTempate(ctx context.Context, smtpHost, smtpPort, fromMail, fromPassword, toMail, tplFile string, mailData map[string]string) error

func Stringer

func Stringer(raw interface{}) string

func Substr

func Substr(input string, start int, length int) string

func SwearDetector

func SwearDetector(message string) ([]string, error)

func VerifyBCrypt

func VerifyBCrypt(testPassword, hash string) error

Verify compares a hashed password with plaintext password

Types

This section is empty.

Jump to

Keyboard shortcuts

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