Thank your lucky stars that we are not setting up our base 64 decoding from the ground up. That would have taken ages. In its place, we have a lovely API that will give us the same results in the merest fraction of the time.
With pip install, our client can be installed very easily.
pip install cloudmersive-convert-api-client
Continuing onward, we need to use this code to call edit_text_base64_decode:
from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = cloudmersive_convert_api_client.Configuration()configuration.api_key['Apikey'] = 'YOUR_API_KEY'# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed# configuration.api_key_prefix['Apikey'] = 'Bearer'# create an instance of the API classapi_instance = cloudmersive_convert_api_client.EditTextApi(cloudmersive_convert_api_client.ApiClient(configuration))request = cloudmersive_convert_api_client.Base64DecodeRequest() # Base64DecodeRequest | Input requesttry:# Base 64 decode, convert base 64 string to binary contentapi_response = api_instance.edit_text_base64_decode(request)pprint(api_response)except ApiException as e:print("Exception when calling EditTextApi->edit_text_base64_decode: %s\n" % e)
Toss in your text string and the API will take care of the decoding. Your response will be the binary form of the original string, easy as pie!