mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-28 07:21:07 +00:00
Merge pull request #324 from cclauss/patch-3
print() is a function in Python 3
This commit is contained in:
commit
2ca8d16af0
|
@ -1,11 +1,12 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
|
||||||
class Onepad:
|
class Onepad:
|
||||||
def encrypt(self, text):
|
def encrypt(self, text):
|
||||||
'''Function to encrypt text using psedo-random numbers'''
|
'''Function to encrypt text using psedo-random numbers'''
|
||||||
plain = []
|
plain = [ord(i) for i in text]
|
||||||
key = []
|
key = []
|
||||||
cipher = []
|
cipher = []
|
||||||
for i in text:
|
|
||||||
plain.append(ord(i))
|
|
||||||
for i in plain:
|
for i in plain:
|
||||||
k = random.randint(1, 300)
|
k = random.randint(1, 300)
|
||||||
c = (i+k)*k
|
c = (i+k)*k
|
||||||
|
@ -22,7 +23,8 @@ class Onepad:
|
||||||
plain = ''.join([i for i in plain])
|
plain = ''.join([i for i in plain])
|
||||||
return plain
|
return plain
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
c,k = Onepad().encrypt('Hello')
|
c, k = Onepad().encrypt('Hello')
|
||||||
print c, k
|
print(c, k)
|
||||||
print Onepad().decrypt(c, k)
|
print(Onepad().decrypt(c, k))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user