Skip to content

Instantly share code, notes, and snippets.

@pyropeter
Created November 22, 2010 22:20
Show Gist options
  • Save pyropeter/710831 to your computer and use it in GitHub Desktop.
Save pyropeter/710831 to your computer and use it in GitHub Desktop.
Looks like real cryptography!
import random
def encrypt(text):
lastchar = random.randint(0,255)
result = chr(lastchar)
for char in text:
lastchar ^= ord(char)
result += chr(lastchar)
return result
def decrypt(text):
result = ""
for i in range(len(text)-1, 0, -1):
result = chr(ord(text[i]) ^ ord(text[i-1])) + result
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment