Created
June 17, 2016 20:25
-
-
Save dotysan/aeafeb8cf317137b2e899ecbada02044 to your computer and use it in GitHub Desktop.
Cheap attempt to generate a random password and its crypt-pw using mostly bash.
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
#! /bin/bash -e | |
# | |
# Cheap attempt to generate a random password and its crypt-pw using mostly bash. | |
# | |
SALT="./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
mkapass() { | |
local len=${1-8} | |
while [ ${n:=1} -le $len ] | |
do let n+=1 | |
pass="$pass${SALT:$[RANDOM%${#SALT}]:1}" | |
done | |
echo "$pass" | |
unset pass n | |
} | |
salt="${SALT:$[RANDOM%${#SALT}]:1}${SALT:$[RANDOM%${#SALT}]:1}" | |
pass=$(mkapass 11) | |
crypt=$(python -c "import crypt; print crypt.crypt('$pass','$salt')") #" | |
echo "password: $pass" | |
echo "crypt-pw: $crypt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment