I am very new to programming and Python so please bear with me. I have a string that is Base64 and I want to convert it to decimal. The string can come in to the script as any value, for example zAvIAQ. This value represents an IP address which is 204.11.200.1 when converted to decimal. What I want to do is convert the Base64 string to decimal and assign it to a variable so that I can use it elsewhere in the script.
I have tried to use the base64.decode function, but that just gives me a very strange text output. I have tried to use the Decimal() function but that gives me an error. After searching for several days now I haven’t found a way to do this, at least not one that I can understand. Any help that you can provide would be appreciated.
First decode the base64-encoded string using
decode('base64')and then decode the resulting number into an IP quartet by usingsocket.inet_ntoa. Like this: