views:

160

answers:

1

In my Python web app, I would need to decrypt a file that was encrypted using VIM. Assuming the web app knows the password used to encrypt the file in VIM, how do I write code to decrypt ?

+4  A: 

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()
Ignacio Vazquez-Abrams
Unfortunately `_ZipDecrypter` is not available in App Engine (or Python 2.5)
Sridhar Ratnakumar
But copying that class into local file works.
Sridhar Ratnakumar