Skip to content

Instantly share code, notes, and snippets.

@egormanga
Created November 28, 2018 23:25
Show Gist options
  • Select an option

  • Save egormanga/c968bababbcb46e92b0f4cbe79d2c14e to your computer and use it in GitHub Desktop.

Select an option

Save egormanga/c968bababbcb46e92b0f4cbe79d2c14e to your computer and use it in GitHub Desktop.
VK MP3 Mod messages de- and encryption
#!/usr/bin/python3
# VK MP3 Mod messages de- and encryption
import argparse
chars = " ​‌‏ "
prefix = "  "
sep = " "
def decrypt(s):
if (not s.startswith(prefix)): return s
return bytearray(sum(chars.index(i[len(i)-j-1])*len(chars)**j for j in range(len(i))) for i in s.replace(prefix, '').split(sep)).decode('utf-8')
def encrypt(s):
text = list()
for i in s.encode('utf-8'):
c = str()
while (i):
c = chars[i % len(chars)]+c
i //= len(chars)
text.append(c)
return prefix+sep.join(text)
def main(d):
print((decrypt if (d) else encrypt)(input()))
if (__name__ == '__main__'):
argparser = argparse.ArgumentParser()
argparser.add_argument('-d', help='Decode', action='store_true')
cargs = argparser.parse_args()
main(cargs.d)
# by Sdore, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment