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 4257800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:33:45+00:00 2026-05-21T05:33:45+00:00

Hey, I’m trying to write a program to convert from a BASE64 string to

  • 0

Hey, I’m trying to write a program to convert from a BASE64 string to a BASE16(HEX) string.

Here’s an example:

     BASE64:   Ba7+Kj3N
HEXADECIMAL:   05 ae fe 2a 3d cd
     BINARY:   00000101 10101110 11111110 00101010 00111101 11001101
    DECIMAL:   5 174 254 42 61 205

What’s the logic to convert from BASE64 to HEXIDECIMAL?
Why is the decimal representation split up?
How come the binary representation is split into 6 section?

Just want the math, the code I can handle just this process is confusing me. Thanks 🙂

  • 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-05-21T05:33:45+00:00Added an answer on May 21, 2026 at 5:33 am

    Read the base64 4 chars at a time, since 4 base64 chars become 3 bytes:

    'Ba7+', 'Kj3N'
    

    Decode each char of the base64. I just looked it up on Wikipedia:

    [1, 26, 59, 62], [10, 35, 55, 13]
    

    Shift the numbers in each group to the left by 18, 12, 6, and 0 respectively:

    >>> def pack(a, b, c, d): return hex((a << 18) + (b << 12) + (c << 6) + d)
    >>> pack(1, 26, 59, 62)
    '0x5aefe'
    >>> pack(10, 35, 55, 13)
    '0x2a3dcd'
    

    Then, if you want to convert to hex yourself, shift them to the right by 4, 8, … 24, 28 to peel off each nybble and convert to a digit from 0 to f.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I'm using Levenshteins algorithm to get distance between source and target string. also
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my
Hey having some trouble trying to maintain transparency on a png when i create
Hey there, I'm at the moment trying to make a product management application. The
Hey I am very new to Web Programming. I have been learning PHP from
Hey guys. I'm trying to configure TFS2010 on a home server. I want to
Hey everybody, i am deploying my code from a cluster running on ubuntu onto
Hey, I'm trying to make an Address book for my site and I was
Hey Forum, So i'm trying to find out how to use the source files
Hey all, i am trying to create a report to show how much is

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.