Created
November 22, 2010 22:20
-
-
Save pyropeter/710831 to your computer and use it in GitHub Desktop.
Looks like real cryptography!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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