tool

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)

const for bytes sizes

View Source
const (
	Minute = 60
	Hour   = 60 * Minute
	Day    = 24 * Hour
	Week   = 7 * Day
	Month  = 30 * Day
	Year   = 12 * Month
)

Seconds-based time units

View Source
const TimeLimitCodeLength = 12 + 6 + 40

TimeLimitCodeLength for Time Verification

Variables

This section is empty.

Functions

func BasicAuthDecode

func BasicAuthDecode(encoded string) (string, string, error)

BasicAuthDecode decodes username and password portions of HTTP Basic Authentication from encoded content.

func BasicAuthEncode

func BasicAuthEncode(username, password string) string

BasicAuthEncode encodes username and password in HTTP Basic Authentication format.

func CreateTimeLimitCode

func CreateTimeLimitCode(data string, minutes int, startInf interface{}) string

CreateTimeLimitCode create a time limit code code format: 12 length date time string + 6 minutes string + 40 sha1 encoded string

func FileSize

func FileSize(s int64) string

FileSize calculates the file size and generate user-friendly string.

func MD5

func MD5(str string) string

MD5 encodes string to MD5 hex value.

func MD5Bytes

func MD5Bytes(str string) []byte

MD5Bytes encodes string to MD5 bytes.

func RandomString

func RandomString(n int) (string, error)

RandomString returns generated random string in given length of characters. It also returns possible error during generation.

func SHA1

func SHA1(str string) string

SHA1 encodes string to SHA1 hex value.

func ShortSHA1

func ShortSHA1(sha1 string) string

ShortSHA1 truncates SHA1 string length to at most 10.

func TimeSincePro

func TimeSincePro(then time.Time) string

TimeSincePro calculates the time interval and generate full user-friendly string.

func VerifyTimeLimitCode

func VerifyTimeLimitCode(data string, minutes int, code string) bool

VerifyTimeLimitCode verify time limit code

Types

This section is empty.

Jump to

Keyboard shortcuts

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