Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pendulum(string):
- result = ""
- side = 0
- while len(string)>0:
- if side == 0:
- result = string[0] + result
- else:
- result = result + string[0]
- string = string[1:]
- side = 1 - side
- return result
- def antipendulum(string):
- result = ""
- index = (len(string)-1) // 2
- swing = 1
- swing_dir = 1
- while index>=0 and index<len(string):
- result += string[index]
- index += swing * swing_dir
- swing += 1
- swing_dir = -swing_dir
- return result
- def encrypt():
- while True:
- pt = input("Plaintext: ")
- if pt == "": break
- ct = pendulum(pt)
- print("Ciphertext: \""+ct+"\"")
- def decrypt():
- while True:
- ct = input("Ciphertext: ")
- if ct == "": break
- pt = antipendulum(ct)
- print("Plaintext: \""+pt+"\"")
- encrypt()
- ##decrypt()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement