Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. encyption = [
  2. 'LpaGbbfctNiPvwdbjnPuqolhhtygWhEuafjlirfPxxl'
  3. ,'WdafvnbcDymxeeulWOtpoofnilwngLhblUfecvqAxs'
  4. ,'UijMltDjeumxUnbiKstvdrVhcoDasUlrvDypegublg'
  5. ,'LpaAlrhGmjikgjdmLlcsnnYmIsoPcglaGtKeQcemiu'
  6. ,'LpaDohqcOzVbglebjPdTnoTzbyRbuwGftflTliPiqp'
  7. ,'ATFW'
  8. ]
  9.  
  10. def charConverter(inChar):
  11. inInt = ord(inChar)
  12. if inInt >= ord('a') and inInt <= ord('z'):
  13. return inInt - ord('a')
  14. elif inInt >= ord('A') and inInt <= ord('Z'):
  15. return inInt - ord('A')
  16. else:
  17. raise Exception("Invalid Char: "+inChar)
  18.  
  19. def decoder(encyptChar,messageChar):
  20. encyptInt = charConverter(encyptChar)
  21. messageInt = charConverter(messageChar)
  22. keyInt = encyptInt - messageInt
  23. if keyInt < 0:
  24. keyInt = 26 + keyInt
  25. # print(decodedInt)
  26. return chr(keyInt + ord('A'))
  27.  
  28.  
  29. while True:
  30. inputValue = input("Enter the Encyption Key:")
  31. count = 0
  32. for encypted in encyption:
  33. output = "Input: "+str(count)+" Encoded Value:"+str(encypted)+" Message:"+inputValue+" key Value: "
  34. index = 0
  35. for messageChar in inputValue:
  36. output = output + decoder(encypted[index],messageChar)
  37. index = index + 1
  38. print(output)
  39. count = count + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement