rand

package
Version: v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2021 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaskSymbols            = "!@#$%^&*()"
	MaskDigits             = "0123456789"
	MaskLetters            = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	MaskLetterSymbols      = "!@#$%^&*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	MaskLetterDigits       = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	MaskLetterSymbolDigits = "!@#$%^&*()0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)

Mask 定义

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(size KeySize) ([]byte, error)

GenerateKey creates a new random secret key.

func GenerateRecommendedKey

func GenerateRecommendedKey() ([]byte, error)

GenerateKey creates a new random recommended secret key.

func RandomBytes

func RandomBytes(n int) ([]byte, error)

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

func RandomDigits(n int) (string, error)

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

func RandomString(n int) (string, error)

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

func RandomStringURLSafe(n int) (string, error)

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

func RandomStringWithMask(mask string, n int) (string, error)

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.

Types

type KeySize

type KeySize int
const (
	KeySize16 KeySize = 16
	KeySize24 KeySize = 24
	KeySize32 KeySize = 32
)

Source Files

Jump to

Keyboard shortcuts

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