Skip to content

Instantly share code, notes, and snippets.

@roshnet
Created April 29, 2024 09:58
Show Gist options
  • Save roshnet/23c1cd1840074cae756500c3183f798a to your computer and use it in GitHub Desktop.
Save roshnet/23c1cd1840074cae756500c3183f798a to your computer and use it in GitHub Desktop.

From https://ss64.com/pass/command-line.html -

# Bash version
strongpw() {
    read -rs -p 'Encryption key: ' key
    echo '' # line break
    echo -n "$key:$1" | sha256sum | perl -ne "s/([0-9a-f]{2})/print chr hex \$1/gie" | base64 | tr +/ Ea | cut -b 1-20
}


# macOS bash version
strongpw() {
    read -rs -p 'Encryption key: ' key
    echo '' # line break
    echo -n "$key:$1" | shasum -a 256 | perl -ne "s/([0-9a-f]{2})/print chr hex \$1/gie" | base64 | tr +/ Ea | cut -b 1-20
}

Example -

$ strongpw paypal
Encryption key:
5h8RDZxO6xyXbaLrxKE6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment