Documentation
¶
Overview ¶
Package random makes the random and derived strings the application hands out: verification codes, tokens and secrets from crypto/rand, and the invite-code encoding of user ids.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeBase62 ¶
EncodeBase62 is the invite-code encoding: id in base 62 over the shuffled chars62 alphabet, most significant digit first, left-padded to six characters. The padding is chars62's last character next to the digits, then every third character before it. The padding makes the encoding irreversible and not injective (916132831 and 56800235583 both give "yyyyyy"); zero encodes as the single character "E" and a negative id as the padding alone. Invite codes are stored and shared, so the output must never change; TestEncodeBase62Golden pins it.
func Key ¶
Key returns length random characters: letters and digits for keyType 1, digits otherwise, as in a verification code.
func StrToDashedString ¶
StrToDashedString inserts a dash after every fourth character, to make a long code readable ("ABCD-EFGH-IJ").
Types ¶
This section is empty.