Decrypt VIM file in Python

In my Python web application, I will need to decrypt a file that has been encrypted using VIM. Assuming the web application knows the password used to encrypt the file in VIM, how do I write code to decrypt it?

+3
source share
2 answers

It turns out that vim uses the same encryption as PKZIP:

from zipfile import _ZipDecrypter

fp = open(somefile, 'rb')
zd = _ZipDecrypter(somekey)

fp.read(12)
print ''.join(zd(c) for c in fp.read())

fp.close()
+7
source

I wrote a tool for this, also supporting more advanced encryption methods:

https://github.com/nlitsme/vimdecrypt

+1
source

Source: https://habr.com/ru/post/1734516/


All Articles