Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8243211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:26:15+00:00 2026-06-07T21:26:15+00:00

I am reading this libb64 source code for encoding and decoding base64 data. I

  • 0

I am reading this libb64 source code for encoding and decoding base64 data.

I know the encoding procedure but i can’t figure out how the following decoding table is constructed for fast lookup to perform decoding of encoded base64 characters. This is the table they are using:

static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};

Can some one explain me how the values in this table are used for decoding purpose.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:26:16+00:00Added an answer on June 7, 2026 at 9:26 pm

    It’s a shifted and limited ASCII translating table. The keys of the table are ASCII values, the values are base64 decoded values. The table is shifted such that the index 0 actually maps to the ASCII character + and any further indices map the ASCII values after +. The first entry in the table, the ASCII character +, is mapped to the base64 value 62. Then three characters are ignored (ASCII ,-.) and the next character is mapped to the base64 value 63. That next character is ASCII /.

    The rest will become obvious if you look at that table and the ASCII table.

    It’s usage is something like this:

    int decode_base64(char ch) {
        if (ch < `+` or ch > `z`) {
            return SOME_INVALID_CH_ERROR;
        }
    
        /* shift range into decoding table range */
        ch -= `+`;
    
        int base64_val = decoding[ch];
    
        if (base64_val < 0) {
            return SOME_INVALID_CH_ERROR;
        }
    
        return base64_val;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading this page http://code.google.com/p/closure-stylesheets/ , I can't seem to find any documentation explaining how
Reading this article http://support.microsoft.com/kb/813878 I have a question: Where can I get ipseccmd.exe for
Reading this question got me thinking: For a given function f , how can
After reading this question I attempted to clean out my workspace and found that
After reading this thread: NSUserDefaults not present on first run on simulator I know
Reading this question , in the first comment, @Cody Gray says: Erm, you know
Reading this old but classic document Writing High-Performance Managed Applications - A Primer ,
Reading this question I found this as (note the quotation marks) code to solve
Reading this question , a doubt popped into my head: char and varchar can
Reading this DZone article about Java concurrency I was wondering if the following code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.