Created
November 28, 2018 23:25
-
-
Save egormanga/c968bababbcb46e92b0f4cbe79d2c14e to your computer and use it in GitHub Desktop.
VK MP3 Mod messages de- and encryption
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
| #!/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