Advertisement
joemccray

Encryption Demo

Apr 4th, 2016
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ####################
  2. # MD5 Hashing Demo #
  3. ####################
  4. mkdir ~/demo
  5. cd ~/demo
  6.  
  7.  
  8.  
  9. mkdir hashdemo
  10. cd hashdemo
  11. echo test > test.txt
  12. cat test.txt
  13. md5sum test.txt
  14. echo hello >> test.txt
  15. cat test.txt
  16. md5sum test.txt
  17. cd ..
  18.  
  19.  
  20.  
  21. #################################
  22. # Symmetric Key Encryption Demo #
  23. #################################
  24. md5sum test.txt
  25. mkdir gpgdemo
  26. cd gpgdemo
  27. echo test > test.txt
  28. cat test.txt
  29. gpg -c test.txt
  30. password
  31. password
  32. ls | grep test
  33. cat test.txt
  34. cat test.txt.gpg
  35. rm -rf test.txt
  36. ls | grep test
  37. gpg -o output.txt test.txt.gpg
  38.  
  39.  
  40. ##################################
  41. # Asymmetric Key Encryption Demo #
  42. ##################################
  43.  
  44. sudo apt-get install rng-tools
  45. strategicsec
  46.  
  47. /etc/init.d/rng-tools start
  48.  
  49. sudo rngd -r /dev/urandom
  50. strategicsec
  51.  
  52.  
  53. echo hello > file1.txt
  54. echo goodbye > file2.txt
  55. echo green > file3.txt
  56. echo blue > file4.txt
  57.  
  58. tar czf files.tar.gz *.txt
  59.  
  60. gpg --gen-key
  61. 1
  62. 1024
  63. 0
  64. y
  65. John Doe
  66. john@doe.com
  67. --blank comment--
  68. O
  69. password
  70. password
  71.  
  72.  
  73.  
  74. gpg --armor --output file-enc-pubkey.txt --export 'John Doe'
  75.  
  76. cat file-enc-pubkey.txt
  77.  
  78. gpg --armor --output file-enc-privkey.asc --export-secret-keys 'John Doe'
  79.  
  80. cat file-enc-privkey.asc
  81.  
  82. gpg --encrypt --recipient 'John Doe' files.tar.gz
  83.  
  84. rm -rf files.tar.gz *.txt
  85.  
  86. tar -zxvf files.tar.gz.gpg
  87.  
  88. gpg --output output.tar.gz --decrypt files.tar.gz.gpg
  89. password
  90.  
  91. tar -zxvf output.tar.gz
  92.  
  93.  
  94. ############################
  95. # Encryption using OpenSSL #
  96. ############################
  97. openssl genrsa -out private_key.pem 1024
  98. openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
  99.  
  100.  
  101. echo hello > encrypt.txt
  102. openssl rsautl -encrypt -inkey public_key.pem -pubin -in encrypt.txt -out encrypt.dat
  103.  
  104. cat encrypt.dat
  105.  
  106. rm -rf encrypt.txt
  107.  
  108. openssl rsautl -decrypt -inkey private_key.pem -in encrypt.dat -out decrypt.txt
  109.  
  110. cat decrypt.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement