1) I use this the most, since I've already generated a key pair
and have the configuration set up to know the default key.
To encrypt with default key:
gpg --encrypt filename
To decrypt with default key to the screen:
gpg --decrypt filename (you could | it to less/more if desired)
To decrypt to a file:
gpg --decrypt f--output savetofilename filename.gpg
If you don't want to use keys which use assymetric encryption,
you can use a simple passwword which uses symmetric encryption.
To encrypt the file doc.txt:
gpg --output doc.gpg --symmetric doc.txt
To decrypt the file doc.gpg:
gpg --output doc.txt --decrypt doc.gpg
2) Another way, right there without any extra installation in
OpenBSD, is openssl.
To encrypt:
openssl enc -des3 -in filename -out filename.des3
To decrypt:
openssl enc -des3 -d -in filename.des3 -out filename
Some notes on openssl:
Don't forget your passphrase and cipher used, e.g., des3.
I should be noted these days most people prefer AES or BlowFish over
3DES. All rules for password length/entropy still apply and some, if
not most, consider keys far stronger.
See openssl(8) for more details. Also see the "-P" switch in rm(1)
for deletion of the original, unencrypted file.
3) Here's a simple way to encrypt a file your editing in vim. This
taken from vim(1):
To encrypt a document with vim open the new or existing file with:
vim -x [file]
This will prompt you for a passphrase, and only apply the encryption
when writing a file. i.e., if you don't save it or write the file it
won't be applied. Use any passphrase you like and the file will be
encrypted to that string. Anytime you open the file after this, even
using the normal open method (vim [file]) it will prompt for the
password before showing any file contents.