ccmny

Szyfr Cezara

Jun 23rd, 2011
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def cipher(string, shift):
  2.     output = ""
  3.     for letter in string:
  4.         output += chr(ord(letter)+shift)
  5.     return output;
  6.  
  7. def decipher(string, shift):
  8.     return cipher(string, -shift)
  9.    
  10. def main():
  11.     string = "Ala ma kota, sierotka ma rysia"
  12.     shift = 5
  13.     print "Tekst do zaszyfrowania: " + string
  14.     string = cipher(string, shift)
  15.     print "Tekst zaszyfrowany: " + string
  16.     string = decipher(string, shift)
  17.     print "Tekst odszyfrowany: " + string
  18.    
  19. if __name__ == "__main__":
  20.     main()
Advertisement
Add Comment
Please, Sign In to add comment