randstr

module
Version: v0.0.0-...-c971ce2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT

README

randstr

Linux/OSX Build Status Windows Build Status 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)
}

Directories

Path Synopsis
cmd
lib
charset
Package charset provides types for defining and using arbritary charsets.
Package charset provides types for defining and using arbritary charsets.
randstr
Package randstr generates random strings (e.g.
Package randstr generates random strings (e.g.
runes
Package runes contains types and interfaces for writing runes.
Package runes contains types and interfaces for writing runes.

Jump to

Keyboard shortcuts

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