Skip to content

Instantly share code, notes, and snippets.

@todd-dsm
Created August 28, 2025 18:55
Show Gist options
  • Select an option

  • Save todd-dsm/98d87caeca595a15f4e78da001296673 to your computer and use it in GitHub Desktop.

Select an option

Save todd-dsm/98d87caeca595a15f4e78da001296673 to your computer and use it in GitHub Desktop.
Generate a strong 32-bit password

Generate Strong Password with OpenSSL

Requirements:

  • 256 bits of entropy from a trusted source: macOS
  • Replaces some characters from SET1 with those specified
  • Snags the first 32 characters

I've stored this script /usr/local/bin/gen-passwd

Further Reading

man pages for

#!/usr/bin/env bash
# PURPOSE: Generate a strong password with:
# * 256 bits of entropy from a trusted source: macOS
# * Replaces some characters from SET1 with those specified
# * Snags the first 32 characters
# -----------------------------------------------------------------------------
# EXECUTE: gen-passwd
# -----------------------------------------------------------------------------
# AUTHOR: todd-dsm (github)
# -----------------------------------------------------------------------------
#set -x
###----------------------------------------------------------------------------
### VARIABLES
###----------------------------------------------------------------------------
# ENV Stuff
###----------------------------------------------------------------------------
### FUNCTIONS
###----------------------------------------------------------------------------
function pMsg() {
theMessage="$1"
printf '\n%s\n\n' "$theMessage"
}
###----------------------------------------------------------------------------
### MAIN PROGRAM
###----------------------------------------------------------------------------
### Generate a strong password
###---
pMsg "Your strong 32-character password:"
openssl rand 256 | tr -dc 'A-Za-z0-9!@#$%^&*()_+-=[]{}|;:,.<>/?' | head -c 32
pMsg ''
###---
### fin~
###---
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment