Created
March 7, 2019 12:31
-
-
Save bing0o/c88611c857829452c16ff07493d50a96 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| import os, time | |
| from Crypto.Cipher import AES | |
| from Crypto.Hash import SHA256 | |
| from Crypto import Random | |
| def decrypt(key, filename): | |
| chunksize = 64 * 1024 | |
| outputFile = filename.split('en')[1] | |
| with open(filename, 'rb') as infile: | |
| filesize = int(infile.read(16)) | |
| IV = infile.read(16) | |
| decryptor = AES.new(key, AES.MODE_CBC, IV) | |
| with open(outputFile, 'wb') as outfile: | |
| while True: | |
| chunk = infile.read(chunksize) | |
| if len(chunk) == 0: | |
| break | |
| outfile.write(decryptor.decrypt(chunk)) | |
| outfile.truncate(filesize) | |
| def getkey(password): | |
| hasher = SHA256.new(password.encode('utf-8')) | |
| return hasher.digest() | |
| key = "sahay" | |
| filename = "enim_msg.txt" #the output file would be "im_msg.txt" | |
| decrypt(getkey(key), filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment