Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decrypt VIM encrypted file in Python

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 ?

like image 872
Sridhar Ratnakumar Avatar asked Aug 17 '26 11:08

Sridhar Ratnakumar


1 Answers

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()
like image 105
Ignacio Vazquez-Abrams Avatar answered Aug 19 '26 03:08

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!