2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00
2021-01-20 02:58:03 +00:00

rands

Go package providing a suite of functions that use `crypto/rand` to generate cryptographically secure random strings in various formats, as well as ints and bytes.

Go Reference GitHub tag (latest SemVer) Actions Status Coverage GitHub issues GitHub pull requests License Status

s, _ := rands.Base64(16)       // => CYxqEdUB1Rzno3SyZu2g/g==
s, _ := rands.Base64URL(16)    // => zlqw9aFqcFggbk2asn3_aQ
s, _ := rands.Hex(16)          // => 956e2ec9e7f19ddd58bb935826926531
s, _ := rands.Alphanumeric(16) // => Fvk1PkrmG5crgOjT
s, _ := rands.Alphabetic(16)   // => XEJIzcZufHkuUmRM
s, _ := rands.Upper(16)        // => UMAGAFPPNDRGLUPZ
s, _ := rands.UpperNumeric(16) // => DF0CQS0TK9CPUO3E
s, _ := rands.Lower(16)        // => ocsmggykzrxzfwgt
s, _ := rands.LowerNumeric(16) // => rwlv7a1p7klqffs5
s, _ := rands.Numeric(16)      // => 9403373143598295

s, _ := rands.String(16, "abcdefABCDEF")                                // => adCDCaDEdeffeDeb
s, _ := rands.UnicodeString(16, []rune("九七二人入八力十下三千上口土夕大")) // => 下下口九力下土夕下土八上二夕大三

s, _ := rands.DNSLabel(16) // => z0ij9o8qkbs0ru-h

n, _ := rands.Int(2147483647)                   // => 1334400235
n, _ := rands.Int64(int64(9223372036854775807)) // => 8256935979116161233

b, _ := rands.Bytes(8) // => [0 220 137 243 135 204 34 63]

Import

import "github.com/jimeh/rands"

Documentation

Please see the Go Reference for documentation and examples.

Benchmarks

Benchmark reports and graphs are available here: https://jimeh.me/rands/dev/bench/

License

MIT

Description
Go package providing a suite of functions that use crypto/rand to generate cryptographically secure random strings in various formats.
Readme MIT 480 KiB
Languages
Go 97.3%
Makefile 2.7%