Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def codeascii(x,codage):
- x = ord(x)
- x -= 65
- x +=codage
- x = x%26
- return chr(x+65)
- def decodeascii(x,codage):
- x = ord(x)
- x -= 65
- x -= codage
- x = x%26
- return chr(x+65)
- def code_phrase(phrase, nbrcodage):
- text=""
- for lettre in phrase:
- text= text + str(codeascii(lettre, nbrcodage))
- return text
- def decode_phrase(phrase, nbrdecode):
- text=""
- for lettre in phrase:
- text= text + str(decodeascii(lettre, nbrdecode))
- return text
- def readtxt(x):
- destination = open("out.txt", "w")
- text= ""
- with open("txt.txt", "r") as fichier:
- text = fichier.read().rstrip('\n\r')
- print(text)
- text = decode_phrase(text, x)
- print(text)
- destination.write(text)
- destination.close()
- fichier.close()
- readtxt(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement