Advertisement
Guest User

a password manager alternative

a guest
Oct 9th, 2015
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.20 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # author: Samuel Gaehwiler
  4. #         www.klangfreund.com
  5. #
  6. # dependencies:
  7. #  7za
  8. #  (on OS X, get it via 'brew install p7zip')
  9. #
  10. # usage:
  11. #  ./encrypt.sh
  12. #
  13. #  To decrypt, use e.g. 'The Unarchiver.app' from the App Store.
  14.  
  15. password=replaceThisWithYourMasterPassword
  16.  
  17. dateAndTime=$(date +\%y\%m\%d_\%H\%M\%S)
  18.  
  19. # Compress and encrypt
  20. # --------------------
  21. # Source: http://xmodulo.com/how-to-create-encrypted-zip-file-on-linux.html
  22.  
  23. backupFileName=$(date +\%y\%m\%d_\%H\%M\%S)_Samuel_Gaehwiler_encrypted.zip
  24.  
  25. returnText=$(7za a -tzip -p$password -mem=AES256 $backupFileName encrypt.sh payload/*)
  26. echo $returnText
  27.  
  28. # Be aware that the list of file names can be viewed without knowing the password!
  29. #   unzip -l <filename>.zip
  30. #
  31. # source: http://security.stackexchange.com/questions/35818/are-password-protected-zip-files-secure/35879#35879
  32.  
  33.  
  34. # Delete the payload if the encryption went well.
  35. # -----------------------------------------------
  36.  
  37. zipSuccessfullyCreated="Everything is Ok"
  38. if test "${returnText#*$zipSuccessfullyCreated}" != "$returnText"
  39. then
  40.     rm -r encrypt.sh payload
  41. else
  42.     echo "The creation of the encoded zip file did not work. Reason unknown."
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement