Many different encoding schemes may be applied to data on smartphones, and frequently, encoding schemes can dictate how user data is stored in third-party applications.
Base64 encoding, which is often applied to data being transported from one system to another (like email), is a popular messaging format because it ensures that the device (and OS) at the opposite end can properly interpret the data that was transmitted. In Base64 encoding, groups of 6 bits are used to represent 64 different binary values. The bytes to be encoded (for example, ASCII) must be divisible by 3. If they are not, they are padded with the "=" symbol. This is the easiest way to quickly identify Base64 encoding when used in mobile applications. The binary bits must be divisible by 6, and if not, they are padded with zeros. This will make more sense after seeing how a short word is converting to Base64 by hand.
Decoding Base64 by hand is not a common practice with the abundance of online and stand-alone solutions that will quickly encode or decode your desired data, however, it is possible, and is a multistep process.
First,
convert your ASCII to binary:
Bug becomes 01000010 01110101 01100111
Bugs becomes 01000010 01110101 01100111 01110011
Bugs. becomes 01000010 01110101 01100111 01110011 00101110
Next, your bits must be divisible by 6, so re-section each into six-bit increments and if not divisible by six, pad the end with zeros until it is.
Bug
becomes 010000 100111 010101 100111 (it is divisible by 6 and requires no padding)
Bugs becomes 010000 100111 010101 100111 011100 110000
Bugs becomes 010000 100111 010101 100111 011100 110010 111000
[Notice that “Bugs” and “Bugs.” required padding with zeros so that the bits were divisible by 6]
Now, convert your 6-bit words you created into decimal. To do this by hand, this handy chart is very useful and can be filled in for each 6-bit word. The first two bits in each word will be zeros.
EX: 010000 binary converts to 16 decimal because all of the places are zero except for 16.
Bug
becomes 16 39 21 39
Bugs becomes 16 39 21 39 28 48
Bugs. becomes 16 39 21 39 28 50 56
Finally, utilize the chart depicted in the previous slide to convert the decimal value to an ASCII character. Base64 utilizes the table shown in the slide to represent the 64 different binary values. The table remains constant, which is how other systems are able to properly decode the data.
Examples
of Base64-encoded ASCII text:
ASCII: Bug Base64: QnVn
ASCII: Bugs Base64: QnVncw==
ASCII: Bugs. Base64: QnVncy4=
A quick look at the ASCII can let you know if you did your conversions right and your results are padded correctly. EX: Bug is 3 units in length and therefore does not require padding, whereas Bugs totals 4 units, so it requires 2 equal signs (==) to make the length of 6, which is now divisible by 3.
Additional Base64 encoding resources are available at the link below.1
Reference:
[1] https://for585.com/base64