Skip to content

Instantly share code, notes, and snippets.

@happyincent
Last active September 24, 2020 08:28
Show Gist options
  • Save happyincent/520cab29b63314223fcabdf259f67467 to your computer and use it in GitHub Desktop.
Save happyincent/520cab29b63314223fcabdf259f67467 to your computer and use it in GitHub Desktop.
encode.py (https://file.io)
#! 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