maroph icon

GPG2: symmetric encrypt/decrypt a file

maroph | PRO | 08/31/17 12:27:26 PM UTC | 0 ⭐ | 400 👁️ | Never ⏰ | []
text |

1.73 KB

|

None

|

0 👍

/

0 👎

First we let us show, which cipher algorithms are supported by our gpg2 version:
 $ gpg2 --version
gpg (GnuPG) 2.1.18
libgcrypt 1.7.6-beta
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
 Home: /home/maro/develop/gpg2Test/gnupg_test
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
  The supported ciphers are: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
 In the following example we use the AES256 cipher and the following test file
 $ cat test.txt
Hello World!
 As passphrase we use the most ingenious string "secret" to encrypt the file text.txt
 $ gpg2 --symmetric --cipher-algo AES256 --batch --passphrase secret --armor test.txt
 The encryption result will be stored in the file test.txt.asc. 
 To decrypt the file we use the following command:
 $ gpg2 --decrypt --batch --passphrase secret test.txt.asc
gpg: AES256 encrypted data
gpg: encrypted with 1 passphrase
Hello World!
 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.
 If you want to use a compression algorithm, e.g. BZIP2, add the option
 --compress-algo BZIP2
 to the above encryption command (option --symmetric)

Comments