SHARE
TWEET

Untitled

a guest Jan 15th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2.  
  3. class cypher():
  4.  
  5.     def __init__(self, text):
  6.         self.text = text
  7.  
  8.     def multiple_replace(text):
  9.         dict = {
  10.             "a": "z",
  11.             "b": "y",
  12.             "c": "x",
  13.             "f": "u",
  14.             "d": "w",
  15.             "e": "v",
  16.             }
  17.  
  18.         # Create a regular expression  from the dictionary keys
  19.         regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
  20.  
  21.         # For each match, look-up corresponding value in dictionary
  22.         return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
  23.  
  24.  
  25. test = input(str('What do you want cyphered. '))
  26.  
  27. fixed = cypher.multiple_replace(test)
  28. print()
  29. print(fixed)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top