Skip to content

Instantly share code, notes, and snippets.

@juliensalinas
Created May 26, 2023 19:45
Show Gist options
  • Select an option

  • Save juliensalinas/15789d241f28b1ce45f0c22e11ba894a to your computer and use it in GitHub Desktop.

Select an option

Save juliensalinas/15789d241f28b1ce45f0c22e11ba894a to your computer and use it in GitHub Desktop.
Encoding a file in base 64 in Python
import base64
with open('your_file.mp3', 'rb') as binary_file:
binary_file_data = binary_file.read()
base64_encoded_data = base64.b64encode(binary_file_data)
base64_output = base64_encoded_data.decode('utf-8')
print(base64_output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment