Created
June 16, 2024 21:08
-
-
Save nijave/499d578460d8ad5ed8964e652bfb88db to your computer and use it in GitHub Desktop.
OpenSSL PBKDF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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