-
Notifications
You must be signed in to change notification settings - Fork 0
/
encrypt_info.py
60 lines (46 loc) · 1.21 KB
/
encrypt_info.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
"""
encrypt_info.py
Import a public key, and encrypt email and password
"""
import os
import sys
import ezPyCrypto
def usage():
print "Usage:"
print "encrypt_info.py [email protected] password"
if len(sys.argv) != 3:
usage()
exit()
email= sys.argv[1]
pwd= sys.argv[2]
print "Email: " + email
print "Password: " + pwd
print "Remember to escape weird characters like $ with a \ this way ~> \$"
directory=os.path.dirname(os.path.realpath(__file__))
# Create a key object
k = ezPyCrypto.key(1280)
# Read in the public key
fd = open(directory+"/.ex_mykey.pub", "rb")
print "Reading public key: .ex_mykey.pub"
pubkey = fd.read()
fd.close()
# import this public key
k.importKey(pubkey)
# Now encrypt the email against this public key
print "Encrypting email..."
enc = k.encString(email)
# Save the encrypted email to disk
print "Saving encrypted email to: email..."
fd = open(directory+"/email", "wb")
fd.write(enc)
fd.close()
# Now encrypt the password against this public key
print "encrypting password..."
enc = k.encString(pwd)
# Save the encrypted password to disk
print "Saving encrypted password to: pwd..."
fd = open(directory+"/pwd", "wb")
fd.write(enc)
fd.close()
print "Success"