Skip to content

Instantly share code, notes, and snippets.

@indifferentcats
Created July 17, 2023 14:06
Show Gist options
  • Save indifferentcats/14568e660082f1d9f9b1d7c63b69bb7a to your computer and use it in GitHub Desktop.
Save indifferentcats/14568e660082f1d9f9b1d7c63b69bb7a to your computer and use it in GitHub Desktop.
Password practice
#!/bin/bash
echo "Type the new password slowly. Ensure that there are no mistakes."
read -s -p "Please enter the new password> " p;
echo " $(printf "$p" | wc -c) characters long"
g=3
while [ $g -ne 0 ]; do
read -s -p "Verify by typing slowly> " c
if [ "$c" == "$p" ]; then
echo " MATCH"
break
else
echo " NOT A MATCH"
g=$[ $g - 1 ]
fi
done
if [ $g -eq 0 ]; then
echo "WARNING: This password was too difficult. Pick a better one."
exit 1
fi
echo "Entering practice stage. Type quicker and in different postures"
echo "to build muscle memory."
practice=1
while [ $practice -ne 0 ]; do
g=3;
while [ $g -gt 0 ]; do
read -s -p "Check ($g left)> " c;
if [ "$p" == "$c" ]; then
g=$[ $g - 1 ];
echo " MATCH";
else
echo " MISS - start again";
g=3;
fi;
done;
echo "Excellent. Practice makes perfect."
read -p "Press ENTER to practice some more. " retry
if [ -n "$retry" ]; then
practice=0
fi
done
@indifferentcats
Copy link
Author

When it's time to change a password I will use all of the time, I like a chance to practice. This script helps me build muscle memory and to confirm that I still like the password after typing it a dozen times. I will practice watching my fingers, in awkward angles, with my eyes closed, and even looking away.
Like my piano teacher taught me, you haven't begun to master something until you can do it three correctly times in a row without a crutch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment