genpw, in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Mark Cornick 56b98fd530 docs(tap): Revert "Note that the Homebrew tap might not work on Catalina" 2 months ago
.github docs(CONTRIBUTING): `master` branch is now `main` 5 months ago
lib feat: use all available letters and digits 3 months ago
.gitignore chore(gitignore): ignore .idea 8 months ago
.gitpod.yml feat(gitpod): Add Gitpod config 1 year ago
.goreleaser.yml feat(notarize): Notarize in addition to codesigning 2 months ago docs(CODE_OF_CONDUCT): add 1 year ago
Dockerfile Start releasing with goreleaser 1 year ago
LICENSE docs(LICENSE): 2020 1 year ago docs(tap): Revert "Note that the Homebrew tap might not work on Catalina" 2 months ago
gon.hcl feat(notarize): Notarize in addition to codesigning 2 months ago
main.go chore(SPDX): Add SPDX-License-Identifiers 11 months ago


Gitpod Ready-to-Code

genpw is a command-line tool that generates strings of random characters that can be used as reasonably secure passwords.

Passwords are, by default, chosen from the union of three character classes: upper-case letters, lower-case letters, and digits.

(Versions prior to 3.0.0 did not use 0, O, I, l, or 1. This was to avoid confusion when passwords are displayed in sans-serif fonts. I no longer consider this important, so versions 3.0.0 and greater use all letters and digits.)

Options can be given to omit any one or any two of these character classes. For instance, you can omit uppercase letters and digits by passing -upper=false -digit=false to genpw. This will return a password composed only of lowercase letters.

Passwords are guaranteed to contain at least one of each selected character class. The default length is 16. genpw will create a password of any length greater than or equal to the number of character classes selected.

If the password length is less than or equal to the total number of characters selected, genpw will not repeat characters within the generated password.


I use this repository to experiment with goreleaser, so there are a ridiculous number of builds and packages available for such a trivial app. Don't judge.

Homebrew (macOS or Linux)

brew install markcornick/tap/genpw

Scoop (Windows)

scoop bucket add markcornick
scoop install genpw

Snap (Linux)

snap install genpw


docker run --rm markcornick/genpw

Binaries and RPM/DEB/APK packages

Here. Checksums from that page are signed with my GPG key. The genpw-notarized.dmg and files contain codesigned and notarized macOS binaries, which you'll need for Catalina.

go get

go get


$ genpw -help
Usage of genpw:
        Include digits (default true)
  -length int
        Length to generate (default 16)
        Include lowercase letters (default true)
        Include uppercase letters (default true)

$ genpw
$ genpw -length=8
$ genpw -length=64
$ genpw -length=0
2017/10/31 16:04:47 Invalid length - must be an integer greater than 2
$ genpw -lower=false
$ genpw -upper=false -length=8
$ genpw -lower=false -upper=false -length=32
$ genpw -lower=false -upper=false -digit=false
2019/08/17 04:29:15 Must include at least one of -lower, -upper and/or -digit
exit status 1

For compatibility with earlier versions of genpw, the length can also be specified as an integer following any flags. A length specified in this manner will override the -length flag.

$ genpw 64
$ genpw -upper=false 8
$ genpw -lower=false -upper=false 32


Bug reports and pull requests are welcome on GitHub at

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


genpw is available as open source under the terms of the MIT License.