Skip to content

Instantly share code, notes, and snippets.

@danielcarr
Last active October 7, 2015 10:34
Show Gist options
  • Save danielcarr/6fd7f55d070248f91f60 to your computer and use it in GitHub Desktop.
Save danielcarr/6fd7f55d070248f91f60 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# hashapass.com method for generating passwords
# based on the script by Simon Elmir at http://hashapass.com/en/cmd.html
export IFS="" #read will now preserve whitespace
read -rp "parameter: " PARAMETER
read -rsp "password: " PASSWORD
echo
read -n 2 -rp "how many characters: " LENGTH
echo
echo -n "$PARAMETER" \
| openssl dgst -sha1 -binary -hmac "$PASSWORD" \
| openssl enc -base64 \
| cut -c 1-${LENGTH:-10}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment