![]() It does it with all other characters, adding them to the " base64" string, which will contain our final encoded text. Meaning base64chars is A, base64chars will retrieve B, etc. 29 th, because indexing starts with 0, not one. Simply put, our first Base64 number is 28, so it will use the 29 th character in the base64chars array, which is c. The same logic applies to the other two parts also.Īfter getting the numeric value of the 6bits of the encoded block, the program maps the numeric value to a character in the base64chars array. On the contrary, the last six 1s of the mask will leave the shifted block intact. Think about it: performing AND between anything and 0 will produce 0. Running AND on the corresponding bits of the shifted block and the number 63 (again, all zeroes, plus 111111) will do just this for us. How can we discard the first, unneeded 011100 part? The algorithm simply uses the AND bitwise operator to accomplish it. But we still have the first 6 bits in the shifted block. The program shifts the block 12 times, so the second 6 bits gets to the far-right position that we need. Now, the second part is more interesting. Running the AND operator between this and the decimal number 63 (which is …111111 in binary) is not necessary this time as all of the bits in front of the shifted block are all 0s. You'll see in our example the last 6bits of the shifted block will become 011100. ![]() To calculate the first 6bit part, the program shifts the 24-bit block to the right 18 times, this way the desired 6 bits will occupy the first 6 bits of the block.
0 Comments
Leave a Reply. |