Instantly share code, notes, and snippets.

Embed
What would you like to do?
A shell script to generate a Lucee Admin password hash using an input string and salt. Suitable for pasting into lucee-*.xml.*
#!/bin/bash
SHA_ALGORITHM=256
SHA_COUNT=5
LUCEE_PASSWORD=${1:-"_"}
LUCEE_SALT=${2:-"_"}
if [ $LUCEE_PASSWORD == "_" ]; then
LUCEE_PASSWORD=topsecret
fi
if [ $LUCEE_SALT == "_" ]; then
LUCEE_SALT=$(uuidgen | tr a-z A-Z)
fi
COUNT=1
LUCEE_HASH=$(echo -n "${LUCEE_PASSWORD}:${LUCEE_SALT}" | shasum -a $SHA_ALGORITHM | cut -f1 -d' ')
while [ $COUNT -lt $SHA_COUNT ]; do
LUCEE_HASH=$(echo -n $LUCEE_HASH | shasum -a $SHA_ALGORITHM | cut -f1 -d' ')
COUNT=$((COUNT + 1))
done
echo "Lucee Admin Values"
echo " hspw = $LUCEE_HASH"
echo " salt = $LUCEE_SALT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment