Advertisement
Guest User

Untitled

a guest
May 5th, 2015
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. def encrypter(intext, shift, modder):
  2. plain = list(intext)
  3. out = ''
  4. j = 0
  5. key = list(shift)
  6. for i in plain:
  7. if mod > 0:
  8. x = chr((ord(i) + ord(key[(j % (len(plain) - 1)) % len(key)]) - 48) % 58 + 48)
  9. if mod < 0:
  10. x = chr(((ord(i) - ord(key[(j % (len(plain) - 1)) % len(key)]) - 48) % 58 + 48))
  11. out += x
  12. j += 1
  13. return out
  14. sel = raw_input("Encrypt (e)/ Decrypt (d)")
  15. if sel == 'e':
  16. mod = 1
  17. elif sel == 'd':
  18. mod = -1
  19. else:
  20. mod = 0
  21. print('Enter a proper value!')
  22. if mod != 0:
  23. print(encrypter(raw_input('Enter the text:'), raw_input('Enter the key-phrase:'), mod)
  24.  
  25. C:Usersaesha_000pyScriptspython.exe "D:/Programming/Computing GCSE/Resources/functiontest3.py"
  26. Encrypt (e)/ Decrypt (d)e
  27. Enter the text:alex
  28. Enter the key-phrase:pass
  29. ]Yd:
  30.  
  31. Process finished with exit code 0
  32.  
  33. C:Usersaesha_000pyScriptspython.exe "D:/Programming/Computing GCSE/Resources/functiontest3.py"
  34. Encrypt (e)/ Decrypt (d)d
  35. Enter the text:]Yd:
  36. Enter the key-phrase:pass
  37. a2e>
  38.  
  39. Process finished with exit code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement