python binary to base64 code example
Example 1: base64 encode python
import base64
message = "Python is fun"
message_bytes = message.encode('ascii')
base64_bytes = base64.b64encode(message_bytes)
base64_message = base64_bytes.decode('ascii')
print(base64_message)
Example 2: decode base64 python
import base64
msg = base64.b64decode(msg)
Example 3: how to convert from binary to base 10 in python
def getBaseTen(binaryVal):
count = 0
binaryVal = binaryVal[::-1]
for i in range(0, len(binaryVal)):
if(binaryVal[i] == "1"):
count += 2**i
return count