A virtual teacher who reveals to you the great secrets of Base64

Base64 Decode Algorithm

The Base64 decode algorithm converts plain text into original data. Technically, it can be said that it converts six-bit bytes into eight-bit bytes. To understand how the decoding algorithm works, check the example below that describes step by step how to manually decode strings from Base64 (if you are looking for an automatic converter, use the Base64 online decoder).

For example, you have the QUJD string and want to decode it from Base64:

  1. First, you need to split the string letter by letter. Thus, you got 4 groups:
    • Q
    • U
    • J
    • D

  2. Each group (letter) is a Base64 character, which has its own index, and now your task is to convert groups to indices. To do this, by mapping values from the Base64 Characters Table, replace each character by its index to get the following:
    • 16
    • 20
    • 9
    • 3

  3. At this step you should convert each group from decimal to binary. So find corresponding decimal values in the ASCII table and make sure you get the following binary values:
    • 00010000
    • 00010100
    • 00001001
    • 00000011

  4. Now convert eight-bit bytes into six-bit bytes by removing the prefix “00” (two zeros) in front of each group:
    • 010000
    • 010100
    • 001001
    • 000011

  5. There you have a simple concatenation of binary values (that is, glue all the groups together and get a 24-character string):
    010000010100001001000011

  6. Then, divide the resulting string into groups so that each one has 8 characters (that is, now you have 3 groups):
    • 01000001
    • 01000010
    • 01000011

  7. Once again using the ASCII table, convert all binary values into their ASCII characters:
    • A
    • B
    • C

  8. The final chord, concatenate all ASCII characters to get the result string:
    ABC

To summarize, you learned that decoding “QUJD” from Base64 yields the result “ABC”. As you can see, this is a very simple process, and I hope that you managed to get the right decoding result. Otherwise, let me know and I will try to help you.

Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.

Loading...