Last active
December 30, 2015 20:39
-
-
Save dtlanghoff/7881763 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python3 | |
import random | |
def shiftCharCode(code, shift): | |
return ((code + shift + 185) % 217) + 32 | |
def shiftString(s, shift): | |
return ''.join(chr(shiftCharCode(ord(i), shift)) for i in s) | |
def shiftRight(s): | |
return shiftString(s, 1) | |
def shiftLeft(s): | |
return shiftString(s, -1) | |
def moveRight(s): | |
return s[-1] + s[:-1] | |
def moveLeft(s): | |
return s[1:] + s[0] | |
def addNoise(s): | |
return s + chr(int(random.random()*58) + 65) | |
def removeNoise(s, dummy=False): | |
return s[:-1] if not dummy else s | |
def main(text, strength): | |
for i in range(strength+1): | |
for j in range(strength-i+1): | |
k = strength-i-j+1 | |
t = text | |
items = {shiftLeft: i, moveLeft: j, lambda s: removeNoise(s, dummy=True): k} | |
l = (f for f in items for d in range(items[f])) | |
for f in l: | |
t = f(t) | |
print(t) | |
if __name__ == '__main__': | |
main('yFiWWox*xs}}ox6*tk*rkx*o|*ox*vs~ox*rs}}sqz|yzz6zW', 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment