Skip to content

Instantly share code, notes, and snippets.

@nijave
Created June 16, 2024 21:08
Show Gist options
  • Save nijave/499d578460d8ad5ed8964e652bfb88db to your computer and use it in GitHub Desktop.
Save nijave/499d578460d8ad5ed8964e652bfb88db to your computer and use it in GitHub Desktop.
OpenSSL PBKDF2
#!/usr/bin/env sh
set -e
pw=$(tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 20)
iterations=100000
eval $(echo -n "$pw" | openssl enc -pbkdf2 -pass pass:/dev/stdin -aes-256-cbc -P -md sha256 -iter $iterations | grep -E '^(salt|key)')
pwHash={PBKDF2}${iterations}\$${salt}\$${key}
echo "$pwHash"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment