How To Password Protect Text Files Using Vim Editor In Linux

Tolkem

Well-Known Member
Joined
Jan 6, 2019
Messages
1,567
Reaction score
1,284
Credits
11,462


How To Password Protect Text Files Using Vim Editor in Linux

File encryption is a way of encoding files, including the sensitive data they contain, in order to send them securely. The encoding prevents unauthorized access and tampering by malicious actors. It keeps a file from being read by anyone except the person or people for whom it was intended.​

Encryption generally takes place through the use of keys.

Method:​

To encrypt an existing file, open the file with vim and press “ESC” key to enter into the command mode, then type command :X to get a prompt to enter the key. Type your key twice and press enter. That's it, the file is protected now.

View attachment 12498

Encryption key: Here, we are providing the key for encrypting the file.


View attachment 12501

View attachment 12502


If a third person tries to access the encrypted file using a wrong key then the file will be corrupted.

View attachment 12500

So, hence a valid encryption key is required so that the data is protected.
Thanks it's help me
 
This should be a tutorial or tip.
I've never been a vi/m user. But if the right circumstance were to present itself, this would be a game-changer.
 
Nice tip, just remember to:

[ESC]
:setlocal cm=blowfish2 [ENTER]

The default encryption is worthless.

/tony
 
I have not specified cryptmethod, so it's using defaults (Fedora 35). I create a file with -x and save the file. On opening the file again, providing passphrase, it shows blowfish2 with the file name, number of lines, and file size. Not sure why yours would behave differently.

VIM version 8.2.4845
 


Top