maroph

GPG2: symmetric encrypt/decrypt a file

Aug 31st, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. First we let us show, which cipher algorithms are supported by our gpg2 version:
  2.  
  3. $ gpg2 --version
  4. gpg (GnuPG) 2.1.18
  5. libgcrypt 1.7.6-beta
  6. Copyright (C) 2017 Free Software Foundation, Inc.
  7. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
  8. This is free software: you are free to change and redistribute it.
  9. There is NO WARRANTY, to the extent permitted by law.
  10.  
  11. Home: /home/maro/develop/gpg2Test/gnupg_test
  12. Supported algorithms:
  13. Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
  14. Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
  15. CAMELLIA128, CAMELLIA192, CAMELLIA256
  16. Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
  17. Compression: Uncompressed, ZIP, ZLIB, BZIP2
  18.  
  19.  
  20. The supported ciphers are: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
  21.  
  22. In the following example we use the AES256 cipher and the following test file
  23.  
  24. $ cat test.txt
  25. Hello World!
  26.  
  27. As passphrase we use the most ingenious string "secret" to encrypt the file text.txt
  28.  
  29. $ gpg2 --symmetric --cipher-algo AES256 --batch --passphrase secret --armor test.txt
  30.  
  31. The encryption result will be stored in the file test.txt.asc.
  32.  
  33. To decrypt the file we use the following command:
  34.  
  35. $ gpg2 --decrypt --batch --passphrase secret test.txt.asc
  36. gpg: AES256 encrypted data
  37. gpg: encrypted with 1 passphrase
  38. Hello World!
  39.  
  40. Hint: as you see from the about --version output, the gpg2 version in use supports the following compression algorithms: Uncompressed, ZIP, ZLIB, BZIP2. The compression will be used before encrypting the file data.
  41.  
  42. If you want to use a compression algorithm, e.g. BZIP2, add the option
  43.  
  44. --compress-algo BZIP2
  45.  
  46. to the above encryption command (option --symmetric)
Advertisement
Add Comment
Please, Sign In to add comment