strand generates string randoms containing alphabets, digits and special characters. The randomness is seeded internally with the timestamp of package initialization.
go get -u github.com/Praseetha-KR/strandpackage main
import (
"fmt"
"github.com/Praseetha-KR/strand"
)
func main() {
fmt.Println(strand.String(24))
}| Method | Character Set | Example |
|---|---|---|
| All supported characters |
Usage:
r := strand.String(20)Output:
vT7+Bt/])o+66H<[GG[s |
|
| Alphabet |
Usage:
r := strand.Alpha(20)Output:
PNsxdCsGyLDEFzQxcZSy |
|
| Alphabet Lowercase |
Usage:
r := strand.AlphaLower(20)Output:
ivkosjouadiecjvdanct |
|
| Alphabet Uppercase |
Usage:
r := strand.AlphaUpper(20)Output:
QUXMYZJUHIOZPOAAASFI |
|
| Alphabet and Digits |
Usage:
r := strand.AlphaNumeric(20)Output:
1CxlOZp3yVwoGeqIjimH |
|
| Digits |
Usage:
r := strand.Numeric(20)Output:
93422189029287851575 |
|
| url-safe characters |
Usage:
r := strand.URLSafe(20)Output:
P~8i1aEP_PGWXyHUVmO8 |
|
| Hexadecimal characters |
Usage:
r := strand.Hex(20)Output:
b0590721d92ce097b8a3 |
|
| Binary digits |
Usage:
r := strand.Binary(20)Output:
10100011000101110011 |
|
| Provided by `characters` param |
Usage:
r, err := strand.From("abc#123", 20)Output:
#1a#cc33ccb2131a1233 |
Author: Praseetha-KR (@void_imagineer)
License: MIT