utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: MIT Imports: 12 Imported by: 5

Documentation

Index

Constants

View Source
const (
	//AlphaUpper all upper alphas chars
	AlphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	//AlphaLower all lowers alphas chars
	AlphaLower = "abcdefghijklmnopqrstuvwxyz"
	//AlphaUpperLower all upper and lowers aplhas chars
	AlphaUpperLower = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
	//AlphaUpperLowerNumeric all upper lowers alphas and numerics
	AlphaUpperLowerNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz"
	//AlphaUpperLowerNumericSpecial all upper lowers alphas, numerics and special chas
	AlphaUpperLowerNumericSpecial = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456890" +
		"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
)

Variables

This section is empty.

Functions

func AppendBytes

func AppendBytes(s ...[]byte) []byte

AppendBytes uses byte buffer to append multiple byte arrays

func AppendString

func AppendString(s ...string) string

AppendString uses byte buffer to append multiple strings

func CreateURLSafeSlug

func CreateURLSafeSlug(input string, suffix int) string

CreateURLSafeSlug creates a url safe slug to use in urls

func CryptPassword

func CryptPassword(password []byte, cost int) ([]byte, error)

CryptPassword bcrypts a password at given costs

func DecodeBase64

func DecodeBase64(b64 string) (string, error)

DecodeBase64 descodes a string to base64

func EncodeBase64

func EncodeBase64(input string) string

EncodeBase64 encodes a string to base64

func GenerateSalt

func GenerateSalt() []byte

GenerateSalt generates a random salt with alphanumerics and some special characters

func IsOneOfStringsEmpty

func IsOneOfStringsEmpty(s ...string) bool

IsOneOfStringsEmpty checks if one of the given strings is empty

func RandomHash

func RandomHash(length int) string

func RandomSecureKey

func RandomSecureKey(length int) []byte

RandomSecureKey returns random character with given length

func SanitizeFilename

func SanitizeFilename(s string) string

SanitizeFilename sanitizes a filename for safe use when serving file

func TrimmedStringIsEmpty

func TrimmedStringIsEmpty(s string) bool

TrimmedStringIsEmpty trims spaces returns true if length is 0

Types

type RandomSource

type RandomSource struct {
	CharsToGen string
}

RandomSource express which chars should be considered

func (RandomSource) RandomSequence

func (r RandomSource) RandomSequence(length int) []byte

RandomSequence returns random character with given length; random source express which chars should be considered

Jump to

Keyboard shortcuts

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