Advertisement
kingbode

Untitled

Oct 17th, 2023
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1.  
  2. from characterDict import char_dict
  3. def get_decrypted(_text):
  4.     # get the count of words in the encrypted text
  5.     wordsList = _text.replace("_"," ").strip().split(" ")
  6.     decrypted_text = ""
  7.  
  8.     # loop through the words and decrypt them
  9.     for word in wordsList:
  10.         # strip the key from the encrypted word
  11.         key = word[0] + word[-1]
  12.         word = word[1:-1]
  13.  
  14.         # decrypt the word
  15.         decrypted_word = ""
  16.         lettersList = word.replace("|"," ").strip().split()
  17.         for letter in lettersList:
  18.             if letter != "":
  19.                 decrypted_word += "".join([k for k,v in char_dict.items() if str(v) == letter])
  20.         decrypted_text += decrypted_word + " "
  21.     return decrypted_text
  22.  
  23.  
  24. encrypted_text = "_1|70|5|12|12|15|3_2|16|25|20|8|15|14|6_3|16|18|15|7|18|1|13|13|5|18|19|9_5|47|27|28|29|30|31|32|33|34|91|2"
  25. print()
  26. print(get_decrypted(encrypted_text))
  27.  
  28.  
  29.  
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement