-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDSSE_dec.py
executable file
·44 lines (34 loc) · 918 Bytes
/
DSSE_dec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Rightpeter'
import rsa
import sys
import os
import re
import zipfile
import myTools
import traceback
enc_pattern = re.compile(r'.*\.enc$')
dec_pattern = re.compile(r'.*\.dec$')
def dec(crypto):
with open('public.pem') as publickfile:
p = publickfile.read()
pubkey = rsa.PublicKey.load_pkcs1(p)
with open('private.pem') as privatefile:
p = privatefile.read()
privkey = rsa.PrivateKey.load_pkcs1(p)
content = ''
while crypto:
enc_message = crypto[:256]
crypto = crypto[256:]
message = rsa.decrypt(enc_message, privkey)
content += message
return content
if __name__ == '__main__':
with open('email_input.txt.enc') as inputfile:
crypto = inputfile.read()
print 'crypto:'
print crypto
content = dec(crypto)
print 'content'
print content