rand

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64

func Base64(len int) (string, error)

Base64 returns a base64 url encoded, unpadded string of random bytes. len is the length of bytes. It should be the multiple of 3 to get a string without padding: len * 8 / 6. 3 bytes -- 4 chars 6 bytes -- 8 chars 9 bytes -- 12 chars Wechat OAuth code has 32 characters, which is 24 bytes long; Wechat Access Token has 110 chars, which is 82.5 bytes? Wechat Refresh Token has 110 chars. OpenID has 28 chars, which is 21 bytes UnionID has 28 chars.

func Bytes

func Bytes(len int) ([]byte, error)

Bytes generates cypto-strong random bytes.

func Hex

func Hex(len int) (string, error)

Hex generates a random hexadecimal number of 2*len chars

func IntRange added in v0.4.7

func IntRange(min, max int) int

IntRange returns, as an int, a non-negative pseudo-random number in [min, max). It panics if either of min <= 0 or max <= 0.

func String

func String(length int) string

String generates a random string from the default charset.

func StringWithCharset

func StringWithCharset(length int, charset string) string

StringWithCharset generates a random string from the passed in charset.

Types

This section is empty.

Jump to

Keyboard shortcuts

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