Encrypt text files with vim

From go2linux.org

We all sometimes needs to encrypt files, but if you are just encrypting text files, there are easier options. One of them is vi or vim. I’m a fan of vim and it is my favorite text editor, it can encrypt files, check spelling, etc. We’ll now learn how to encrypt files using vim or vi.

How to encrypt text files with vim/vi

Encrypt a file using Linux vi / vim, is easy just use the -x option when you create the file.

vim -x some-text-file.txt

Now vim will ask you for a password to able to decrypt the file later for you.

Be sure to remember your password, or you will not be able to decrypt your file, actually you will not be able to open your file.

Let’s see an example of an encrypted file, suppose this is the content of the file.

This is an example of how vim can encrypt files in Linux.
This file, will be encrypted and then I will ‘cat’ them to see if they are encrypted.

This is how it looks, if you do not have the password.

cat some-text-file.txt
VimCrypt~01!Jâêà)ÃMéÑ#ª5dÂgL¯=ǶËÐïØFoà¸ff¯#¥áZ1^ê$ÔîAõÄP÷Ö¬k%¼ïv{½v\¢â?¡hA|äá)áø¼o#-&õ®ý=Ìú]xxô~’Ë£ñ6Of#øOÀêÅÁ²ÛÒ¨:³a¹]yJw¼¬fÔ

And if you open it with vim, and do not enter the correct encryption password, you will something similar.

From go2linux.org

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....