Created
May 23, 2018 17:24
-
-
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
This file contains 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
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