Last active
January 24, 2025 03:53
-
-
Save lukebakken/7b4da46ed9abb7ed14f7a60b49f9e52e to your computer and use it in GitHub Desktop.
RabbitMQ - Create Hashed User Password
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 bash | |
set -o errexit | |
set -o nounset | |
declare -r passwd="${1:-newpassword}" | |
declare -r tmp0="$(mktemp)" | |
declare -r tmp1="$(mktemp)" | |
function onexit | |
{ | |
rm -f "$tmp0" | |
rm -f "$tmp1" | |
} | |
trap onexit EXIT | |
dd if=/dev/urandom of="$tmp0" count=4 bs=1 > /dev/null 2>&1 | |
cp -f "$tmp0" "$tmp1" | |
echo -n "$passwd" >> "$tmp0" | |
openssl dgst -binary -sha256 "$tmp0" >> "$tmp1" | |
openssl base64 -A -in "$tmp1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment