tags:

views:

94

answers:

2

I'm having one doubt about the VIM ENCRYPTION key.

I having a text file, I encrypted that file using

:X

Now, where the encrypted key is stored (path).

Whether it stored in a separate file or the text file itself.

If I open a the file it asked Encryption key.

How it compare my key with the original key?

+1  A: 

The key is not saved, you have to enter it by yourself. It wouldn't make any sense to save the key as well, because everyone can decrypt the file with the stored key. If you open the file in vim again it ask for the encryption key.

Progman
+1  A: 

It doesn't store the key - it just encrypts or decrypts with the key you type.

Here's a hex dump of a 15-character file encrypted with a key ('elephant' - try it; the contents was not meaningful ('abcdededesdasd') before I encrypted it):

0x0000: 56 69 6D 43 72 79 70 74 7E 30 31 21 95 96 C7 F6   VimCrypt~01!....
0x0010: 75 C8 3B BF 1D BD BD 86 97 32 DA                  u.;......2.
0x001B:

It's 27 characters long; 'VimCrypt~01!' is 12 characters. If you decrypt it with the wrong key (say 'pinkpanther'), you get garbage. So, vim does no integrity checking on the encrypted file or decrypted file.

Jonathan Leffler