Last active
May 25, 2023 11:33
-
-
Save rssowmiyan/a3d0b6c58d095f410fdb7e72273ea587 to your computer and use it in GitHub Desktop.
base64 payload sample
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
import base64 | |
with open("image.png", "rb") as image_file: | |
encoded_image_string = base64.b64encode(image_file.read()) | |
payload = { | |
"mime" : "image/png", | |
"image": encoded_image_string, | |
"some_other_data": None | |
} | |
# If you want to decode | |
image_as_bytes = str.encode(payload.image) # convert string to bytes | |
img_recovered = base64.b64decode(image_as_bytes) | |
try: | |
with open("uploaded_" + filename, "wb") as f: | |
f.write(img_recovered) | |
with open("615.pdf","rb") as pdf_file: | |
encoded_pdf_string = base64.b64encode(pdf_file.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment