Go2Linux | Linux Operating System

A site dedicated to: Linux Operating System

How to encrypt text files with vi or vim in Linux

Date: 2010-12-13 00:00:00 -0400

Console logo

Introduction

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.

If you liked this article please share it.

powered by TinyLetter

If you want to contact me in any other way, please use the contact page.