-
-
Save trim21/b60d3999bea03bcac403380d4b157a02 to your computer and use it in GitHub Desktop.
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
from urllib.parse import parse_qs, quote, unquote_to_bytes, urlparse | |
raw_bytes = bytes.fromhex('123456789abcdef123456789abcdef123456789a') | |
url = f'https://example.com/?q={quote(raw_bytes)}' | |
print(url) | |
assert unquote_to_bytes(quote(raw_bytes)) == raw_bytes | |
parsed_q = parse_qs(urlparse(url).query).get("q")[0].encode() | |
print(parsed_q.hex()) # 12345678efbfbdefbfbdefbfbdefbfbd234567efbfbdefbfbdefbfbdefbfbd12345678efbfbd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment