mirror of
https://github.com/jimeh/rands.git
synced 2026-02-18 19:16:38 +00:00
ef9cb3a01d1697ea383e4cd315e1eaa84322d84a
pkg.go.dev parses "RFC 1035, section 2.3.1" style text and links it to the relevant place. So there's no need to also include a full URL for documentation purposes.
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.
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
Languages
Go
97.3%
Makefile
2.7%