Advertisement
calcpage

CSH2012 LAB10 ROT13.py

May 8th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. #!/usr/bin/python
  2. #lab10-rot13encoder.py  MrG 2013.0428
  3. input = open("out-grinch.txt","r")
  4. output = open("out2-grinch.txt","w")
  5.  
  6. encoded=""
  7.  
  8. for email in input:
  9.     for i in range(len(email)):
  10.         if (ord(email[i])>=97 and ord(email[i])<=122):
  11.             encoded =  encoded + chr(((ord(email[i])+13)-97)%26+97)
  12.         elif (ord(email[i])>=65 and ord(email[i])<=90):
  13.             encoded =  encoded + chr(((ord(email[i])+13)-65)%26+65)
  14.         else:
  15.             encoded =  encoded + email[i]
  16.  
  17. output.write(encoded)
  18.  
  19. input.close()
  20. output.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement