Advertisement
metalx1000

Basics of Openssl file encryption

Nov 11th, 2023
1,268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.96 KB | None | 0 0
  1. #encrypt text
  2. echo "this is a test"|openssl aes-256-cbc -salt -pbkdf2
  3. echo "this is a test"|openssl aes-256-cbc -salt -pbkdf2 -out output_01.enc
  4. echo "this is a test"|openssl aes-256-cbc -salt -pbkdf2 > output_02.enc
  5.  
  6. #decrypt text
  7. openssl aes-256-cbc -d -salt -pbkdf2 -in output_01.enc
  8.  
  9. #encypt files
  10. #create test files
  11. echo -e "this is a test\nand this is some text\nand a 3rd line for testing" > file.txt
  12. wget "https://filmsbykris.com/v7/img/tux.png"
  13.  
  14. openssl aes-256-cbc -salt -pbkdf2 -in file.txt -out file.enc
  15. openssl aes-256-cbc -salt -pbkdf2 -in tux.png -out tux.enc
  16.  
  17. #decrypt
  18. openssl aes-256-cbc -d -salt -pbkdf2 -in file.enc
  19. openssl aes-256-cbc -d -salt -pbkdf2 -in file.enc -out file_01.txt
  20.  
  21. cat file_01.txt
  22.  
  23. #encrypt tar.gz file/directory
  24. tar -cz * |openssl aes-256-cbc -salt -pbkdf2 -out backup.tar.gz.enc
  25.  
  26. #decrypt tar.gz
  27. #create dir to extract to
  28. mkdir backup
  29. openssl aes-256-cbc -d -salt -pbkdf2 -in backup.tar.gz.enc| tar xz -C backup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement