Skip to content

Instantly share code, notes, and snippets.

@cmndrsp0ck
Created May 23, 2018 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmndrsp0ck/e5cd51aa7db45218d70482532cb412e6 to your computer and use it in GitHub Desktop.
Save cmndrsp0ck/e5cd51aa7db45218d70482532cb412e6 to your computer and use it in GitHub Desktop.
Function to generate WordPress auth salt that's safe to pass through Jinja template
function makeSalt() {
# Create variable length passwords
LC_CTYPE=C;
local saltine=$(tr -dc 'A-Za-z0-9_@#$%^&*~!?;`./|:{} <>[]()-+=' < /dev/urandom | head -c 64)
if [[ $(echo ${saltine} | grep -P '({%|%}|{#|#}|{{|}}|##)') ]]; then
makeSalt;
else
echo "${saltine}";
fi
}
# you can throw the funtion or source the file
# just store the output to a variable
# AUTH_KEY="$(makeSalt)"
# SECURE_AUTH_KEY="$(makeSalt)"
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment