Without public key
GPG
# encrypt
gpg -c khmel.tar.gz
# decrypt
gpg khmel.tar.gz.gpg
OpenSSL
# encrypt
openssl des3 -salt -in khmel.tar.gz -out encryptedfile.txt
# decrypt
openssl des3 -d -salt -in encryptedfile.txt -out khmel.tar.gz
With public key
$ gpg --gen-key
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 2
Key expires at Mon 16 Feb 2009 04:13:08 PM EET
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: khmel.org
Email address: test@khmel.org
Comment: test
You selected this USER-ID:
"khmel.org (test) <test@khmel.org>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
<moving mouse, press different key on keyboard>
gpg: key EA1D37CB marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 2 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 2u
gpg: next trustdb check due at 2009-02-16
pub 1024D/EA1D37CB 2009-02-14 [expires: 2009-02-16]
Key fingerprint = FAD0 8249 4BAF B464 3121 D058 71D0 3EAA EA1D 37CB
uid khmel.org (test) <phn@khmel.org>
sub 2048g/DB5F05BA 2009-02-14 [expires: 2009-02-16]
Prepare public key
gpg --export --armor > alpha-public-key.asc
Using public key
Import
gpg --import /home/alpha/Desktop/beta-public-key.asc
List keys
$ gpg --list-key
/home/alpha/.gnupg/pubring.gpg
---------------------------------- pub 1024D/EA1D37CB 2009-02-14 [expires: 2009-02-16]
uid khmel.org (test) <test@khmel.org>
sub 2048g/DB5F05BA 2009-02-14 [expires: 2009-02-16]
pub 1024D/4B9A45AF 2009-02-14 [expires: 2009-02-17]
uid beta (test) <beta@khmel.org>
sub 2048g/1C413E51 2009-02-14 [expires: 2009-02-17]
Encrypt file
gpg -e -r 'beta' /home/alpha/Desktop/secret.txt
[/bahs]
Decrypt file
gpg -d /home/beta/Desktop/secret.txt.gpg
```