2 parents d4b4b7b + d4594da commit 2ca8d16Copy full SHA for 2ca8d16
1 file changed
ciphers/Onepad_Cipher.py
@@ -1,11 +1,12 @@
1
+from __future__ import print_function
2
+
3
4
class Onepad:
5
def encrypt(self, text):
6
'''Function to encrypt text using psedo-random numbers'''
- plain = []
7
+ plain = [ord(i) for i in text]
8
key = []
9
cipher = []
- for i in text:
- plain.append(ord(i))
10
for i in plain:
11
k = random.randint(1, 300)
12
c = (i+k)*k
@@ -21,8 +22,9 @@ def decrypt(self, cipher, key):
21
22
plain.append(chr(p))
23
plain = ''.join([i for i in plain])
24
return plain
-
25
26
27
if __name__ == '__main__':
- c,k = Onepad().encrypt('Hello')
- print c, k
28
- print Onepad().decrypt(c, k)
+ c, k = Onepad().encrypt('Hello')
29
+ print(c, k)
30
+ print(Onepad().decrypt(c, k))
0 commit comments