Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- import textUtils
- def Enc(text, key):
- alpha = list(string.ascii_uppercase)
- text = textUtils.noUmlauts(text)
- text = text.upper()
- while len(key) < len(text):
- key = key+key
- text = list(text)
- key = key.upper()
- key = list(key)
- dectext = ""
- for i in text:
- if i in alpha:
- index = alpha.index(i)+alpha.index(key[text.index(i)])
- shift = index % 26
- i = alpha[shift]
- dectext = dectext + i
- print(dectext)
- def Dec(text, key):
- alpha = list(string.ascii_uppercase)
- text = textUtils.noUmlauts(text)
- text = text.upper()
- while len(key) < len(text):
- key = key+key
- text = list(text)
- key = key.upper()
- key = list(key)
- dectext = ""
- for i in text:
- if i in alpha:
- index = alpha.index(i)-alpha.index(key[text.index(i)])
- shift = index % 26
- i = alpha[shift]
- dectext = dectext + i
- print(dectext)
- #----------------------------textUtils.py in my Pastebin-------------------------------#
Advertisement
Add Comment
Please, Sign In to add comment