Skip to content

Instantly share code, notes, and snippets.

@raykrueger
Created May 5, 2011 15:59
Show Gist options
  • Save raykrueger/957311 to your computer and use it in GitHub Desktop.
Save raykrueger/957311 to your computer and use it in GitHub Desktop.
Generating secure repeatable passwords with OpenSSL
#!/bin/bash
# see http://www.openssl.org/docs/apps/passwd.html
DOMAIN=$1
PEPPER=55e730a3
SALT=`echo ${PEPPER}${DOMAIN} | shasum | cut -c 1-8`
openssl passwd -1 -salt $SALT | cut -d '$' -f 4
@raykrueger
Copy link
Author

Usage example...
$ passgen github.com
Password: bullshit
ayywx5h0ljGsUgyrYOSGn0

The point here is that you can use a simple to remember word or phrase to generate a secure password. Rather than trying to remember (and type) a very complicated one.

The domain name passed is used as the salt for the password. The domain passed is combined with a fixed value, called PEPPER, and then passed to shasum to get a unique, repeatable, salt.

@raykrueger
Copy link
Author

The previous commit used a fixed salt, I like passing the domain name better.

@raykrueger
Copy link
Author

With version 7f63f1 I switched to combining the domain with a fixed PEPPER value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment