Advertisement
Guzzox

Untitled

Jan 20th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def codeascii(x,codage):
  2. x = ord(x)
  3. x -= 65
  4. x +=codage
  5. x = x%26
  6. return chr(x+65)
  7.  
  8. def decodeascii(x,codage):
  9. x = ord(x)
  10. x -= 65
  11. x -= codage
  12. x = x%26
  13. return chr(x+65)
  14.  
  15. def code_phrase(phrase, nbrcodage):
  16. text=""
  17. for lettre in phrase:
  18. text= text + str(codeascii(lettre, nbrcodage))
  19. return text
  20.  
  21.  
  22. def decode_phrase(phrase, nbrdecode):
  23. text=""
  24. for lettre in phrase:
  25. text= text + str(decodeascii(lettre, nbrdecode))
  26. return text
  27.  
  28. def readtxt(x):
  29. destination = open("out.txt", "w")
  30.  
  31. text= ""
  32.  
  33. with open("txt.txt", "r") as fichier:
  34. text = fichier.read().rstrip('\n\r')
  35.  
  36. print(text)
  37. text = decode_phrase(text, x)
  38. print(text)
  39.  
  40. destination.write(text)
  41.  
  42. destination.close()
  43. fichier.close()
  44.  
  45.  
  46. readtxt(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement