I'm trying to use a service which "base64 converts" their data which they then push to my server. The data is divided into three data types: strings, integers and booleans. Why they package it this way I don't understand, but it's up to me to decipher it.
I have a string Qjo0MDk2 which should convert to B:4096 and PHP's native base64_decode function works!
However, if I try to convert AAATmg== to a base-10 (decimal) integer value, I want to get 5018, but base64_decode just gives me nothing. (I assume because it's trying to convert to a string, rather than a base-10 integer.)
Likewise, AA== should convert to 0 in base-2 (binary) boolean values, while AQ== should convert to 1 in the same.
Is there a set of functions that does this already somewhere? I can't imagine this is new. Here is a website that does it today, but the code is not exposed: https://conv.darkbyte.ru/
base64_decodedoes give you something but it's binary, so if you dump it, it's just a character there is no actual character for (= the symbol with the question mark in it). There are functions to convert binary to decimal (and hex), tests show that I get0if I trybindec. It actually works if I go first to hexadecimalhexdec(bin2hex(base64_decode(...))).5018appears to beNTAxOA==notAAATmg==.AA==should give0andAQ==should give1. Code:if(base64_decode("AA==")) echo "true"; else echo "false";