webtools

package module
v0.0.0-...-dcf6204 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 12 Imported by: 2

README

webtools

golang library contains common helper functions for things like password hashing, generating random strings, encryption, etc.

install

go get github.com/stephenhu/webtools

Documentation

Index

Constants

View Source
const (
	AT_SYMBOL    = "@"
	SPACE_SYMBOL = " "
	EMAIL_REGEXP = "([\\w-.+]+)@([\\w-.]+)"
)
View Source
const (
	HASHTAG_POUND      = "#"
	HASHTAG_MAX_LENGTH = 33
)
View Source
const (
	HASHTAG_REGEXP  = "#[a-z0-9]{1,32}"
	HASHTAG_INVALID = "+,?-_.@$%^&*#!"
)
View Source
const (
	MENTION_AT          = "@"
	USERNAME_MAX_LENGTH = 25
)
View Source
const (
	USERNAME_REGEXP  = "@[a-z][a-z0-9_]{1,23}"
	USERNAME_INVALID = "+,?-.@$%^&*#!"
)
View Source
const (
	APP_NAME    = "webtools"
	APP_VERSION = "1.0"
)
View Source
const (
	ERR_BLOCK_IV_LENGTH_MISMATCH = "Block key and IV length mismatch"
	ERR_EMPTY_BLOCK_IV           = "Block key or IV is empty"
	ERR_EMPTY_TEXT               = "Text empty"
)
View Source
const (
	STR_EMPTY = ""
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(encText string, blockKey string,
	iv string) ([]byte, error)

func Encrypt

func Encrypt(clearBuf []byte, blockKey string,
	iv string) (string, error)

func ExtractHashtags

func ExtractHashtags(s string) []string

func ExtractMentions

func ExtractMentions(s string) []string

func GenerateHash

func GenerateHash(s string, salt string, hk string, p string,
	length int) (string, error)

func GenerateHashAndSalt

func GenerateHashAndSalt(s string, hk string, p string, length int) (
	string, string, error)

func GenerateRandomHex

func GenerateRandomHex(length int) (string, error)

func GenerateSimpleHash

func GenerateSimpleHash(s string, length int) (string, error)

func GenerateToken

func GenerateToken(key string, length int) (string, error)

func HelloWorld

func HelloWorld()

func IsValidEmail

func IsValidEmail(email string) bool

func ParseNameFromEmail

func ParseNameFromEmail(email string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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