Advertisement
Guest User

Password Keeper

a guest
Apr 12th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.60 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4. echo "
  5. ##########################################################################
  6. #                        Password Keeper                                 #
  7. #                                                                        #
  8. ##########################################################################"
  9.  
  10. gpg --version >/dev/null || { echo "This program requires gpg"; exit 1; }
  11. createDir() {
  12.     if [ ! -d ~/Documents/PasswordKeeper ]; then
  13.     mkdir ~/Documents/PasswordKeeper
  14.     echo "Created ~/Documents/PasswordKeeper"
  15.     sleep 1
  16.     fi
  17.     intro
  18. }
  19. enterPass(){
  20.     echo "Enter the website or username:"
  21.     read lock | grep -q "[[:space:]]" || echo "No spaces. Try again"; read lock;
  22.     echo "Enter the password:"
  23.     read -s key
  24.     echo "Repeat password:"
  25.     read -s repeatKey
  26.     while [ $key != $repeatKey ]
  27.     do
  28.     echo "Passwords did not match. Enter password again:"
  29.     read -s repeatKey
  30.     done
  31.     touch $lock.txt; echo $key > $lock.txt
  32.     mv $lock.txt ~/Documents/PasswordKeeper
  33.     clear
  34.     echo -e "Enter Master Password to encrypt:\n"
  35.     gpg -c ~/Documents/PasswordKeeper/"$lock.txt"
  36.     rm -rf ~/Documents/PasswordKeeper/"$lock.txt"
  37.     echo "Done!"
  38.     sleep 1
  39.     intro
  40. }
  41. viewPass(){
  42.     ls ~/Documents/PasswordKeeper
  43.     echo -e "\nChoose a file:"
  44.     read choice
  45.     gpg --decrypt ~/Documents/PasswordKeeper/$choice*
  46.     echo -e "\nPress any key to continue"; read ;
  47.     clear; clear;
  48.     intro
  49. }
  50. intro(){
  51. echo "1) View password"
  52. echo "2) Enter new password"
  53. echo "3) Exit"
  54. read choice
  55.  
  56. case $choice in
  57.     1) clear; viewPass ;;
  58.     2) clear; enterPass ;;
  59.     3) clear; exit 1 ;;
  60.     *) clear; intro ;;
  61. esac
  62. }
  63. createDir
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement