Documentation ¶
Index ¶
- Constants
- func GenerateKey(size KeySize) ([]byte, error)
- func GenerateRecommendedKey() ([]byte, error)
- func RandomBytes(n int) ([]byte, error)
- func RandomDigits(n int) (string, error)
- func RandomString(n int) (string, error)
- func RandomStringURLSafe(n int) (string, error)
- func RandomStringWithMask(mask string, n int) (string, error)
- type KeySize
Constants ¶
const ( MaskSymbols = "!@#$%^&*()" MaskDigits = "0123456789" MaskLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" MaskLetterSymbols = "!@#$%^&*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" MaskLetterDigits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" MaskLetterSymbolDigits = "!@#$%^&*()0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
Mask 定义
Variables ¶
This section is empty.
Functions ¶
func GenerateKey ¶
GenerateKey creates a new random secret key.
func GenerateRecommendedKey ¶
GenerateKey creates a new random recommended secret key.
func RandomBytes ¶
RandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandomDigits ¶ added in v2.5.1
RandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandomString ¶
RandomString returns a securely generated random digits string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandomStringURLSafe ¶
RandomStringURLSafe returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func RandomStringWithMask ¶
RandomStringWithMask returns a securely generated random string with a mask string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.