Documentation
¶
Overview ¶
Package shash will generate a random, base-62, base-36, and base-10 string with user defined length without nonsense. Usage Example:
func main() { h := shash.New(10) gen, _ := h.Generate() fmt.Println(gen) }
Index ¶
Constants ¶
View Source
const ( CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" CHARSET_BASE_36 = "abcdefghijklmnopqrstuvwxyz0123456789" CHARSET_BASE_10 = "0123456789" VERSION = "0.1.0" )
The base62 charset as const CHARSET.
Variables ¶
View Source
var ( MAX_LEN = int64(len(CHARSET) - 1) MAX_LEN_BASE_36 = int64(len(CHARSET_BASE_36) - 1) MAX_LEN_BASE_10 = int64(len(CHARSET_BASE_10) - 1) )
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash struct {
Length int
}
Hash only has one property: Length, with default value of 5 on creation.
func (*Hash) Generate ¶
Generate() will return a random string in base62. Error will return if there is an error with the crypto/rand package, nil if there isn't any error.
func (*Hash) GenerateBase10 ¶
func (*Hash) GenerateBase36 ¶
Click to show internal directories.
Click to hide internal directories.