Tool for generating random strings (e.g. passwords) supporting unicode and emojis.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/randstr
lib
.appveyor.yml
.gitignore
.travis.yml
LICENSE
Makefile
README.md

README.md

randstr

Linux/OSX Build Status Windows Build Status Codecov Go Report Card Go docs

Randstr is a package and a CLI that generates random strings (e.g. passwords), supporting unicode and emojis.

Install

Mac

brew install 4d63/randstr/randstr

Linux/Mac

curl -o /usr/local/bin/randstr https://raw.githubusercontent.com/leighmcculloch/randstr/binaries/$(uname -s | tr '[:upper:]' '[:lower:]')/amd64/randstr && chmod +x /usr/local/bin/randstr

Windows

Download the executable, and save it in your path.

Source

go install 4d63.com/randstr/cmd/randstr

Usage

$ randstr
Ne*!Z|us'VRu;waO53_g{%*gwbY,vY\nw\wR/"5^cg1JkJ`k`l

On Mac, you can pipe the output directly to the clipboard with:

$ randstr | pbcopy

Change the charset:

$ randstr -charset ASCII
NKpZTyBWA;nq3!Lo9qE0OtUC#-Q{UR{I8W"CJFO2u\zam!Nt6c
$ randstr -charset ASCIIUppercase,ASCIINumeric
A9B6VPQG7S3Y0B8QAU16GJGQ2X8HGV24JWOP3NEO84Q7QM416S
$ randstr -charset UnicodeEmoji -l 10
🔙🐨👲🐌🙎🌀👹👾🌺👣
$ randstr -chars 0123456789abcdef
fb972ac28f98ae872a1f42ec707d2f7e0061e22f45e9703275
$ randstr -charset ASCII,UnicodePassword
ʵƦƅȿͺɄϬɚYʩʜLJ͢ȠίϾϺ�Ą̑�ȬˁȞ̈́Ȫˑdžȿˀϡʪͻ'ɕ̉ȷNjɃȨƱϷυ[ʦ�Ζϗ�̮

Package

Use the package by go getting and importing:

go get 4d63.com/randstr/...
import (
  "crypto/rand"
  "4d63.com/randstr/lib/randstr"
  "4d63.com/randstr/lib/charset"
)

func main() {
  password, err := randstr.String(rand.Reader, charset.ASCII, 50)
  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }
  fmt.Printf("Password: %s\n", password)
}