Last active
September 24, 2020 08:28
-
-
Save happyincent/520cab29b63314223fcabdf259f67467 to your computer and use it in GitHub Desktop.
encode.py (https://file.io)
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
#! python3 | |
import base64, binascii, json, urllib.request | |
s1 = 'Hello, World!' | |
code = base64.b64encode(binascii.hexlify(s1[::-1].encode('utf-8'))).decode('utf-8') | |
s2 = bytes.fromhex(base64.b64decode(code).decode('utf-8')).decode('utf-8')[::-1] | |
assert s1 == s2 | |
link = json.loads(urllib.request.urlopen("https://file.io", data='text={}'.format(code).encode('utf-8')).read())['link'] | |
link = base64.b64encode(link.encode('utf-8')).decode('utf-8') | |
# s3 = bytes.fromhex(base64.b64decode(urllib.request.urlopen(base64.b64decode(link).decode('utf-8')).read()).decode('utf-8')).decode('utf-8')[::-1] | |
# assert s1 == s3 | |
print("python -c \"import urllib.request, base64; print(bytes.fromhex(base64.b64decode(urllib.request.urlopen(base64.b64decode('{}').decode('utf-8')).read()).decode('utf-8')).decode('utf-8')[::-1])\"".format(link)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment