-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (24 loc) · 901 Bytes
/
main.py
File metadata and controls
30 lines (24 loc) · 901 Bytes
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
from blowfish import Blowfish
if __name__ == '__main__':
if not Blowfish.testVectors():
print "WARNING: The implementation doesn't pass algorithm test vectors!"
else:
print "The implementation passes algorithm test vectors (ECB)."
key = open("key.txt","r").read()
cipher = Blowfish(key)
# print "Testing block encrypt:"
# text = 'testtest'
# print "\tText:\t\t%s" % text
# crypted = cipher.encrypt(text)
# print "\tEncrypted:\t%s" % repr(crypted)
# decrypted = cipher.decrypt(crypted)
# print "\tDecrypted:\t%s" % decrypted
print "Testing CTR encrypt:"
cipher.initCTR()
text = str(open("input.txt", "r").read())
print "\tText:\t\t", text
crypted = cipher.encryptCTR(text)
print "\tEncrypted:\t", repr(crypted)
cipher.initCTR()
decrypted = cipher.decryptCTR(crypted)
print "\tDecrypted:\t", decrypted