Advertisement
mgostih

Best Xor Encryption

Dec 14th, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def encryption(m,k):
  2.     ret = ""
  3.     for i in range(len(m)):
  4.         ret += chr(ord(m[i])^ord(k[i%(len(m)-1)]))
  5.     return ret
  6. if __name__ == "__main__":
  7.     print("Let's try the program!")
  8.     m = input("Write the message to process: ")
  9.     k = input("Write the key here: ")
  10.     if len(k)<len(m):
  11.         k = k*len(m)
  12.     print("Your cyphertext is: \n %s" %encryption(m,k))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement