Vim logo vim online Vim Book Ad

basic Tip #371: Encrypting a file within vim session and not leaving behind traces.

 tip karma   Rating 7/4, Viewed by 275 

created:   November 20, 2002 21:44      complexity:   basic
author:   Prakash Patil      as of Vim:   6.0

I was desperately looking for a simple way to encrypt files.
(I find this very useful. Despite all the user permissions you set, it's easy for someone/admin
to do sudo and read your personal files..Many work environments provide users the permission
to sudo or become super user)

Vim let's you encrypt file within the edit session.

:X

Will prompt for encryption key. Enter the encryption key and REMEMBER to save
it using :w. That will encrypt the file.

Try
:help  :X
for more info.

If you don't want to leave behind traces of your edits:
By default, once you finish your vim session, ~/.viminfo will be written with
the  files you edited (marks), commands you entered and possibly what you wrote
(the registers you copied or pasted...). If you don't want such trace to be left behind,
then place the following file in in your .vimrc

set viminfo='0,\"0,\/0,:0,f0

 rate this tip  Life Changing Helpful Unfulfilling 

<<always cd to the current file's directory | Remove unwanted empty or blank lines for english and chinese >>

Additional Notes

sorry, no spam please, November 20, 2002 23:22
There are a lot of other vim settings to make sure you leave no trace behind like swapfiles, backupfiles, etc.

I once investigated these settings and set up a gvimrc file for editing files containing
e. g. a collection of 'secret' information like passwords, ident numbers, etc..
I copied this encrypted file, gvimrc, and the program files (gvim.exe) on a 3.5" Floppy,
which makes you 'autarkic'.

I'm trying hard not to forget copying the settings to the VIM tips.

Does anybody know how 'safe' is gvim encryption ?

Thomas
vim_power, November 21, 2002 11:29
from VIM help files.
- The algorithm used is breakable.  A 4 character key in about one hour, a 6
  character key in one day (on a Pentium 133 PC).  This requires that you know
  some text that must appear in the file.  An expert can break it for any key.
  When the text has been decrypted, this also means that the key can be
  revealed, and other files encrypted with the same key can be decrypted.
- Pkzip uses the same encryption, and US Govt has no objection to its export.
  Pkzip's public file APPNOTE.TXT describes this algorithm in detail.
- Vim originates from the Netherlands.  That is where the sources come from.
  Thus the encryption code is not exported from the USA.

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo