Linux :How to encrypt text file in Linux (VIM)

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]

[kartook@Nilas ~]$ vim -x kartook.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 “kartook.txt” text file is encrypted with my password.

Ok, let try to view the text file content

[kartook@Nilas ~]$ cat kartook.txt
VimCrypt~01!??PR?
??0?????$%^&*(        ?W#?Q?W?
(L??Y??
[kartook@Nilas ~]$

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.

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

Done

Possibly Related Posts:


3 comments to Linux :How to encrypt text file in Linux (VIM)

  • Scott

    Now we have an encrypted text file. So, how do we decrypt it to view and edit it?

  • Matt

    @Scott, you simply use vim to open the encrypted file $ vim encrypted.txt
    it will then say:

    Need encryption key for “encrypted.txt”
    Enter encryption key:

    Then enter the key and it will open.

  • Thanks for the tip dude

    –K~

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>