Created
January 21, 2014 11:30
-
-
Save sysr-q/8538444 to your computer and use it in GitHub Desktop.
YOLO SWAG
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
text = input() | |
def decrypt(text): | |
plaintext = [] | |
for word in text.split(): | |
w, w1 = [], [] | |
# Chunk letters | |
letters = word.split("$$$$") | |
for i, c in enumerate(letters): | |
if i%2: | |
if c == "$w@G": | |
w.append("0") | |
elif c == '5wig': | |
w.append('#') | |
else: | |
w.append("1") | |
else: | |
if c == "YoL0": | |
w.append("0") | |
elif c == '5wig': | |
w.append('#') | |
else: | |
w.append("1") | |
w = "".join(w) | |
# De-binary | |
n = 7 | |
binaries = [w[i:i+n] for i in range(0, len(w), n)] | |
for b in binaries: | |
w1.append(chr(int(b.strip("#"), 2))) | |
plaintext.append("".join(w1)) | |
return " ".join(plaintext) | |
print(decrypt(text)) |
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
text = input() | |
def encrypt(text): | |
cipher = [] | |
for word in text.split(): | |
w, w1 = [], [] | |
for c in word: | |
w.append(bin(ord(c))[2:].ljust(7, "#")) | |
#print("?", w) | |
w = "".join(w) | |
for i, c in enumerate(w): | |
if i%2: | |
if c == '0': | |
w1.append("$w@G") | |
elif c == '#': | |
w1.append("5wig") | |
else: | |
w1.append("Y0Lo") | |
else: | |
if c == '0': | |
w1.append('YoL0') | |
elif c == '#': | |
w1.append('5wig') | |
else: | |
w1.append("Sw3G") | |
#print(">?", w1[-1], c) | |
w1.append("$$$$") | |
cipher.append("".join(w1).rstrip("$$$$")) | |
cipher = " ".join(cipher) | |
return cipher | |
print(encrypt(text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment