This Golang-based command-line password generator with optional use of the ChatGPT-4 API, generates secure passwords as well as memorable, AI-enhanced passphrases and sentences in English. These unique features provide a balance between memorability and security. The tool is cross-platform, working on Mac, Linux, Unix, and Windows.
Language | Operating Systems | Shell Support |
---|---|---|
- passwordgen
- Signing up for a ChatGPT-4 API key
- Setting the GPT_API_KEY environment variable
- Building releases for multiple platforms
See the latest release binaries for Mac (Intel or ARM), Linux, or Windows.
$ git clone https://github.com/tcpiplab/passwordgen.git
$ cd passwordgen
$ go build passwordgen.go
$ ./passwordgen 20
βββββ¬βββββββββββββββββββββββ
β 0 β ]Be6ITzc%*ZpZe{]XWvY β
βββββΌβββββββββββββββββββββββ€
β 1 β 3E1zUVaSw4CtU13NE]H) β
βββββΌβββββββββββββββββββββββ€
β 2 β %l2VuZSt8Iu96CEB#Phm β
βββββΌβββββββββββββββββββββββ€
β 3 β mkEBj!t0oW5[xU[sDSad β
βββββΌβββββββββββββββββββββββ€
β 4 β hF[tKgW!QXpzUvSDt8r( β
βββββΌβββββββββββββββββββββββ€
β 5 β WWTh%6fEbSm5su^JDn6b β
βββββΌβββββββββββββββββββββββ€
β 6 β }oHBNXgX5FKIVE@yU8uK β
βββββΌβββββββββββββββββββββββ€
β 7 β 2Lw@Z8oXq@*JxV}mI9[k β
βββββΌβββββββββββββββββββββββ€
β 8 β n5NQ35DJYr3QU7*J7q8z β
βββββ΄βββββββββββββββββββββββ
Enter an integer: 5
Input has been copied to clipboard.
Waiting for 60 seconds before clearing the clipboard.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ60
$ ./passwordgen -h
Usage of ./passwordgen:
-erase
./passwordgen --erase[=false] (default true)
-examples
./passwordgen --examples
-grammatical
./passwordgen --grammatical
-grammatical-ai
./passwordgen --grammatical-ai (Requires an openai.com GPT-4 API key)
-grammatical-ai-with-numbers
./passwordgen --grammatical-ai-with-numbers (Requires an openai.com GPT-4 API key)
-help
./passwordgen -h
-hex
./passwordgen --hex
-interactive
./passwordgen --interactive[=false] (default true)
-memorable
./passwordgen --memorable
-memorable-2
./passwordgen --memorable-2
-memorable-3
./passwordgen --memorable-3
-mnemonic
./passwordgen --mnemonic (Requires an openai.com GPT-4 API key)
-passphrases
./passwordgen --passphrases
-random
./passwordgen --random (default true)
-word-chains
./passwordgen --word-chains
In the examples below, notice that the trailing digit specifying length (20 in this example) is required for all commands. But the various commands comply with the length specification to varying degrees. Some are absolutely strict, others are approximate, sentences ignore it.
$ ./passwordgen --examples 15
βββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββ
β --grammatical β Didn't we unbearably water any opinion? β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --grammatical-ai β Don't succumb to his pressure. β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --grammatical-ai-with-numbers β Their 0 monstrous vehicles didn't cause any cases. β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --hex β 7C326D21 β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --memorable β {%1337}Paradox β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --memorable-2 β =Spinner7 β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --memorable-3 β 4?ThatOrganises β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --memorable-4 β ShinyPaintbrushes~5Easels β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --mnemonic β Tswi28plim β
β β This script, which is 28 pages long, is mine. β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --passphrases β playoff august uninstall lid tricking β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --random β ^OV2oDK1 β
βββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β --word-chains β evolve*jeeringly β
βββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββ
The --grammatical
, grammatical-ai
,--grammatical-ai-with-numbers
, and --mnemonic
options will each generate grammatically correct sentences for use as passphrases. But the latter three options use AI to improve the sentences and will make a lot more sense to you. Use of the AI options requires that you have a valid GPT-4 API key in an environment variable named GPT_API_KEY
.
./passwordgen --grammatical-ai --interactive=false
βββββ¬ββββββββββββββββββββββββββββββββββββββββββ
β 0 β Then, they didn't deduce. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 1 β Is it time to sail? β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 2 β Help the willing man. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 3 β Their impossible series didn't succeed. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 4 β That is through the window. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 5 β Undermine my assumption. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 6 β Don't leave their stupidity. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 7 β He patted her well-worn bottom. β
βββββΌββββββββββββββββββββββββββββββββββββββββββ€
β 8 β Grill a united dish. β
βββββ΄ββββββββββββββββββββββββββββββββββββββββββ
./passwordgen --grammatical-ai-with-numbers --interactive=false
βββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 0 β Their score of 77 is not average. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1 β Cook 37 cups of rice happily. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2 β Eleven of them shall crossly brandish their fee. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3 β It vehemently condemned the 96 degree climate. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4 β Thirteen people encroached on someone's rain. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5 β Request his help with the task of 87. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 6 β At 27 years old, someone's youth is theirs to enjoy. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 7 β The subject is 42 pounds plump. β
βββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 8 β Conduct 0 operations. β
βββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Hex pins must be 4 or more characters long.
passwordgen --hex 4
βββββ¬βββββββ
β 0 β FC70 β
βββββΌβββββββ€
β 1 β DA10 β
βββββΌβββββββ€
β 2 β 2DB6 β
βββββΌβββββββ€
β 3 β C314 β
βββββΌβββββββ€
β 4 β D186 β
βββββΌβββββββ€
β 5 β 5139 β
βββββΌβββββββ€
β 6 β D760 β
βββββΌβββββββ€
β 7 β 5B32 β
βββββΌβββββββ€
β 8 β 48F4 β
βββββ΄βββββββ
For --memorable
passwords, the length is only a rough guide, not deterministic. Values longer than 12 will tend to create passwords that include more than one word.
/passwordgen --memorable 12
βββββ¬ββββββββββββββββ
β 0 β [856]Unglue β
βββββΌββββββββββββββββ€
β 1 β 1423(Unfazed) β
βββββΌββββββββββββββββ€
β 2 β {Landowner}4 β
βββββΌββββββββββββββββ€
β 3 β [552]Juror β
βββββΌββββββββββββββββ€
β 4 β Errand{1796} β
βββββΌββββββββββββββββ€
β 5 β 138[Revenge] β
βββββΌββββββββββββββββ€
β 6 β Groove{1768} β
βββββΌββββββββββββββββ€
β 7 β (Getup)1691 β
βββββΌββββββββββββββββ€
β 8 β Cadillac{780} β
βββββ΄ββββββββββββββββ
For --memorable-2
passwords, the length is only a rough guide, not deterministic. Values longer than 12 will tend to create passwords that include more than one word.
./passwordgen --memorable-2 --interactive=false 20
βββββ¬βββββββββββββββββββββββββ
β 0 β 3Avaricious|Cousin β
βββββΌβββββββββββββββββββββββββ€
β 1 β Exalted+Level8 β
βββββΌβββββββββββββββββββββββββ€
β 2 β 7Vigorous$Permission β
βββββΌβββββββββββββββββββββββββ€
β 3 β Elementary%Set2 β
βββββΌβββββββββββββββββββββββββ€
β 4 β 2Vibrant@Relative β
βββββΌβββββββββββββββββββββββββ€
β 5 β 6Meek:Agency β
βββββΌβββββββββββββββββββββββββ€
β 6 β %8Well-lit/Chain% β
βββββΌβββββββββββββββββββββββββ€
β 7 β Affectionate`Designer6 β
βββββΌβββββββββββββββββββββββββ€
β 8 β Smooth=Arm9 β
βββββ΄βββββββββββββββββββββββββ
./passwordgen --memorable-3 --interactive=false
ββββββ¬ββββββββββββββββββββββββββ
β 0 β ExtrovertedClue$1918 β
ββββββΌββββββββββββββββββββββββββ€
β 1 β DevotedRole*12 β
ββββββΌββββββββββββββββββββββββββ€
β 2 β UnnaturalRoof_2015 β
ββββββΌββββββββββββββββββββββββββ€
β 3 β BlandSituation%00 β
ββββββΌββββββββββββββββββββββββββ€
β 4 β DisfiguredHoliday,2023 β
ββββββΌββββββββββββββββββββββββββ€
β 5 β UglySpeaker/1908 β
ββββββΌββββββββββββββββββββββββββ€
β 6 β IllegalTitle_99 β
ββββββΌββββββββββββββββββββββββββ€
β 7 β BlaringHome?11 β
ββββββΌββββββββββββββββββββββββββ€
β 8 β SubduedMethod@1941 β
ββββββΌββββββββββββββββββββββββββ€
β 9 β RegularEngineering?1976 β
ββββββΌββββββββββββββββββββββββββ€
β 10 β NovelNecessary;2023 β
ββββββΌββββββββββββββββββββββββββ€
β 11 β UnconsciousEqual'99 β
ββββββ΄ββββββββββββββββββββββββββ
These are perhaps the most memorable type of passwords offered by this program. The constituent words are chosen by the ChatGPT-4 API. Then this program optionally pluralizes one noun, depending on the random digit generated, and adds a delimiter before concatenating it all into a password.
/passwordgen --memorable-4
βββββ¬ββββββββββββββββββββββββββββββ
β 0 β Trees%5Roots,Ominous β
βββββΌββββββββββββββββββββββββββββββ€
β 1 β Drums%2Cymbals,Metallic β
βββββΌββββββββββββββββββββββββββββββ€
β 2 β Orchid!1Petal,Fragrant β
βββββΌββββββββββββββββββββββββββββββ€
β 3 β 4Clarets-ExquisiteDecanters β
βββββΌββββββββββββββββββββββββββββββ€
β 4 β DisgustingCats-0Litterboxes β
βββββΌββββββββββββββββββββββββββββββ€
β 5 β Car#1Wheel,Rotating β
βββββΌββββββββββββββββββββββββββββββ€
β 6 β 3Pianos_GrandBenches β
βββββΌββββββββββββββββββββββββββββββ€
β 7 β CreativeDirectors.4Actors β
βββββΌββββββββββββββββββββββββββββββ€
β 8 β 5Boats:SecludedHarbors β
βββββ΄ββββββββββββββββββββββββββββββ
The memorable sentence is generated manually but with random inputs, then improved by ChatGPT-4, which requires an API key. But the resulting mnemonic password is created deterministically by this program.
./passwordgen --mnemonic --interactive=false
βββββ¬βββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 0 β Iywoywf14dwt β If you work on your weaknesses for 14 days, will they. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1 β Nfo64wbataic β No fortune of 64 will be able to alter its course. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2 β 76soyhsnbf β 76 sections of your highway should not be fragmented. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3 β T95-ybwriao β The 95-year-old bell will ring in an old. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4 β G57pt β Give 57 people thanks. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5 β 14pwns β 14 purchases were not successful. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 6 β Hf85%i β Hector felt 85% insecure. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 7 β Sposiist β Seventeen percent of someone's income is sometimes taxed. β
βββββΌβββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 8 β Ismbf25m β I snuggled my blanket for 25 minutes. β
βββββ΄βββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The example below shows use of the -passphrases
feature as well as the optional feature -interactive=false
so that a list of passphrases is simply printed to the screen and the program exits. This example is run in Powershell on Windows 10 but works on all platforms.
PS C:\Users\somebody\Downloads> .\passwordgen-v1.3.0-windows-amd64.exe -passphrases -interactive=false
ββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββ
β 0 β active stalling dubbed almighty entity β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1 β tying wireless relish levitate outwit β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2 β unreeling angelic camper augmented hardhat β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3 β had humble polish legume external β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 4 β regime twilight risk outburst overarch β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 5 β hazing move uncle clustered dehydrate β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 6 β sizzling singer predict surplus debtor β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 7 β division imprudent tapeless unbounded console β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 8 β replica cabbage regress detector purifier β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 9 β denote ancient customize tidal puppy β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 10 β sworn scraggly sandstorm crayon untapped β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 11 β deceiver bunny subpanel decathlon lifting β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 12 β unvalued could easter polymer unlimited β
ββββββΌββββββββββββββββββββββββββββββββββββββββββββββββ€
β 13 β legroom caretaker reference frantic genetics β
ββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββ
The --word-chains
flag requires an argument for how long the passwords will be. Each resulting password will be approximate, depending on the length of the words it is composed of. The length argument must be the last value on the command line.
./passwordgen -word-chains 20
βββββ¬βββββββββββββββββββββββββββββββ
β 0 β obsolete+falsify+tapping β
βββββΌβββββββββββββββββββββββββββββββ€
β 1 β batch=ecosystem=tribune β
βββββΌβββββββββββββββββββββββββββββββ€
β 2 β opponent#kindly#flagstone β
βββββΌβββββββββββββββββββββββββββββββ€
β 3 β comply_footwork_account β
βββββΌβββββββββββββββββββββββββββββββ€
β 4 β coronary+certainly+discard β
βββββΌβββββββββββββββββββββββββββββββ€
β 5 β pedigree&batboy&italicize β
βββββΌβββββββββββββββββββββββββββββββ€
β 6 β poise|unbridle|hunchback β
βββββΌβββββββββββββββββββββββββββββββ€
β 7 β swipe:iciness:clip:doozy β
βββββΌβββββββββββββββββββββββββββββββ€
β 8 β device-dreary-ranch-linoleum β
βββββ΄βββββββββββββββββββββββββββββββ
You can sign up for a ChatGPT-4 API key here. It will cost you a little bit of money each time you use it. At the time of this writing it is pretty cheap. For example, so far it has cost me less than $3.00 to develop and test all the AI features of this program. And they allow you to set soft and hard limits so that you don't accidentally spend too much money.
This is optional. But some of the most interesting features of this tool require this environment variable in order to make calls to the ChatGPT-4 API. Without it these features won't work:
--examples
--grammatical-ai
--grammatical-ai-with-numbers
--memorable-4
--mnemonic
The examples below are for if you're using the zsh
shell. If you're not using the zsh
shell, the ~/.zshrc
file should be replaced with whichever file is appropriate for the shell you're using and how your shell is set up. If you're using the zsh
shell, then just follow the example below. If you're using the bash
shell then here's the rule of thumb:
- If you want your changes to be available in all shell sessions (both login and non-login), place them in
~/.bashrc
and make sure that your~/.bash_profile
sources your~/.bashrc
file. This is usually already set up for you by the OS install scripts. - If you want your changes to only apply to login shells (like when you ssh into your machine), put them in
~/.bash_profile
.
If you're using another shell like ksh
, tcsh
, csh
, or sh
, then I'm sure you know exactly what you're doing and can figure out how to set environment variables with no problem.
echo 'export GPT_API_KEY="xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"' >> ~/.zshrc
source ~/.zshrc
You'll have to do this as root or use sudo
. Either way, I assume that you know what you're doing if you have this level of authorization.
sudo echo 'export GPT_API_KEY="xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"' > /etc/profile.d/myenvvars.sh
To set a permanent environment variable that persists across sessions and reboots, you can use the [System.Environment]::SetEnvironmentVariable()
method. For example, to set a user-level environment variable use the following command but replace the xx-xxxxxxxx...
key value with your own key value. Leave the User
field just like you see below:
[System.Environment]::SetEnvironmentVariable("GPT_API_KEY", "xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "User")
After setting this permanent environment variable, you need to restart your PowerShell session for the changes to take effect.
To set a machine-level (system-wide) environment variable you need to run PowerShell with administrative privileges. Leave the Machine
field just like you see below:
[System.Environment]::SetEnvironmentVariable("GPT_API_KEY", "xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "Machine")
Now restart your computer for the changes to take effect.
setx GPT_API_KEY "xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Now close your cmd
window and open another one.
To set a system-wide environment variable (as opposed to a user-specific one), you need to run the cmd
shell as an administrator and use the /M
switch:
setx /M GPT_API_KEY "xx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Now close your cmd
window and open another one. For other users to use the environment variable you may have to reboot.
GOOS=darwin GOARCH=arm64 go build -o Release-Binaries/v1.10.x/passwordgen-v1.10.0-darwin-arm64
GOOS=darwin GOARCH=amd64 go build -o Release-Binaries/v1.10.x/passwordgen-v1.10.0-darwin-amd64
GOOS=windows GOARCH=amd64 go build -o Release-Binaries/v1.10.x/passwordgen-v1.10.0-windows-amd64.exe
GOOS=linux GOARCH=amd64 go build -o Release-Binaries/v1.10.x/passwordgen-v1.10.0-linux-amd64