joemccray

Encryption Demo

Apr 4th, 2016
1,004
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. --blank comment--
  67. O
  68. password
  69. password
  70.  
  71.  
  72.  
  73. gpg --armor --output file-enc-pubkey.txt --export 'John Doe'
  74.  
  75. cat file-enc-pubkey.txt
  76.  
  77. gpg --armor --output file-enc-privkey.asc --export-secret-keys 'John Doe'
  78.  
  79. cat file-enc-privkey.asc
  80.  
  81. gpg --encrypt --recipient 'John Doe' files.tar.gz
  82.  
  83. rm -rf files.tar.gz *.txt
  84.  
  85. tar -zxvf files.tar.gz.gpg
  86.  
  87. gpg --output output.tar.gz --decrypt files.tar.gz.gpg
  88. password
  89.  
  90. tar -zxvf output.tar.gz
  91.  
  92.  
  93. ############################
  94. # Encryption using OpenSSL #
  95. ############################
  96. openssl genrsa -out private_key.pem 1024
  97. openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
  98.  
  99.  
  100. echo hello > encrypt.txt
  101. openssl rsautl -encrypt -inkey public_key.pem -pubin -in encrypt.txt -out encrypt.dat
  102.  
  103. cat encrypt.dat
  104.  
  105. rm -rf encrypt.txt
  106.  
  107. openssl rsautl -decrypt -inkey private_key.pem -in encrypt.dat -out decrypt.txt
  108.  
  109. cat decrypt.txt
Advertisement
Add Comment
Please, Sign In to add comment