Skip to content

Instantly share code, notes, and snippets.

@sysr-q
Created January 21, 2014 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sysr-q/8538444 to your computer and use it in GitHub Desktop.
Save sysr-q/8538444 to your computer and use it in GitHub Desktop.
YOLO SWAG
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))
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