Kruptos is a simple tool that encrypts and decrypts the ~/.kruptos directory with the password that is stored in ~/.kruptos/.phrazein. There are 3 commands:
- e - Encrypt
- d - Decrypt
- i - Initialize
Goal
I have a couple main goals:
- Design: How could I make this more resilient to change?
- Readability: How could I make this more readable?
- Best Practices: Are there aspects of a bash command that I am missing?
# Minimalist password manager
function kruptos
{
# Decipher the flag
if [[ $# -eq 1 ]]; then
DOWHAT="$1"
else
DOWHAT="d"
fi
# Perform an action
if [[ $DOWHAT == "d" ]]; then
#Decrypt
pushd . &>/dev/null
cd ~/
openssl aes-256-cbc -d -in .kruptos.tar.gz.aes | tar -xz -f - --strip-components=2 && rm ~/.kruptos.tar.gz.aes
popd &>/dev/null
elif [[ $DOWHAT == "e" ]]; then
#Encrypt
tar -zcf - ~/.kruptos | openssl aes-256-cbc -out ~/.kruptos.tar.gz.aes -kfile ~/.kruptos/.phrazein && rm -r ~/.kruptos
elif [[ $DOWHAT == "i" ]]; then
#Initialize
mkdir ~/.kruptos
echo pswd > ~/.kruptos/.phrazein
else
echo "$DOWHAT is not an acceptable flag"
fi
}