Skip to content

Commit d4594da

Browse files
author
cclauss
authored
print() is a function in Python 3
1 parent d4b4b7b commit d4594da

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

ciphers/Onepad_Cipher.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
from __future__ import print_function
2+
3+
14
class Onepad:
25
def encrypt(self, text):
36
'''Function to encrypt text using psedo-random numbers'''
4-
plain = []
7+
plain = [ord(i) for i in text]
58
key = []
69
cipher = []
7-
for i in text:
8-
plain.append(ord(i))
910
for i in plain:
1011
k = random.randint(1, 300)
1112
c = (i+k)*k
@@ -21,8 +22,9 @@ def decrypt(self, cipher, key):
2122
plain.append(chr(p))
2223
plain = ''.join([i for i in plain])
2324
return plain
24-
25+
26+
2527
if __name__ == '__main__':
26-
c,k = Onepad().encrypt('Hello')
27-
print c, k
28-
print Onepad().decrypt(c, k)
28+
c, k = Onepad().encrypt('Hello')
29+
print(c, k)
30+
print(Onepad().decrypt(c, k))

0 commit comments

Comments
 (0)