Most of us keep important notes, login credentials, and other sensitive information in text files.
However, it is unsafe to keep this information in plain text.
One of the ways to protect sensitive information is to use encryption.
Vim has some built-in file-encryption features that let you secure sensitive information using different encryption methods.
Only a person with the right key can then jump into the encrypted file.
Lets see how you could use Vim to encrypt text files in Linux.
Now go toInsert modeby pressing theikey and add the text you want to include in the file.
You will have to enter the key twice.
Enter the key twice to avoid any typos.
Then, edit your file and once you’re done, save and quit Vim.
If you do not enter the correct key, Vim will convert your content into some garbage content.
Never save the file in such a situation otherwise your file will be overwritten by the garbage content.
Then, throw in the encryption key to jump into the content.
While in theCommand mode, bang out:
It will ask you for the encryption key.
jot down a new key and then retype it to confirm.
To remove encryption, just hitEntertwice without typing any key.
However, note that encryption methods like zip and blowfish offered by Vim are not strong.
you should use only blowfish2 which is a strong encryption method.