Main Tutorials

How to encrypt text file in Linux (VIM)

It is very easy to encrypt a text file in Linux, VIM text editor can be used to achieve it.. vim -x [file name]


mkyong@snake ~]$ vim -x mkyong.txt

This will prompt us to enter encryption key (password)


Enter encryption key : ******
Enter same key again: ******

After that, key in the text data and save it. Now the “mkyong.txt” text file is encrypted with my password.

Ok, let try to view the text file content


[mkyong@snake ~]$ cat mkyong.txt
VimCrypt~01!??PR?
??0?????         ?W#?Q?W?
         (L??Y??
[mkyong@snake ~]$ 

The text file content is encrypted with some alien code :), Done, no body can view the content unless they know my encryption key.

How to change the encrypted password?

We can issue the following command (vim +X [file name]) to change the encrypted password.


mkyong@snake ~]$ vim +X mkyong.txt
"mkyong.txt" [crypted] 1L, 37C
Enter encryption key: ***
Enter same key again: ***

Done

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
simplyencrypt
6 years ago

Nice Blog!!

Abhishek Raw
10 years ago

great work

i do this when i encrypt my small script file then after my script is not Runing.
how i make it possible to run and make my file secure also.
if any solution plz mail me at:- [email protected]