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

  • Home
  • SEARCH
  • 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 6619137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:55:40+00:00 2026-05-25T20:55:40+00:00

I am having some difficulty changing a hex to an int/char (char preferably). Via

  • 0

I am having some difficulty changing a hex to an int/char (char preferably). Via the website;
http://home2.paulschou.net/tools/xlate/ I enter the hex of C0A80026 into the hex box, in the DEC / CHAR box it correctly outputs the IP I expected it to contain.

This data is being pulled from an external database and I am not aware how it is being saved so all I have to work with is the hex string itself.

I have tried using the binascii.unhexlify function to see if I could decode it but I fear that I may not have a great enough understanding of hex to appreciate what I am doing.

Attemping to print just using an int() cast also has not produced the required results. I need some way to convert from that hex string (or one similar) to the original IP.

UPDATE: For anyone who comes across this in the future I modified the below answer slightly to provide an exact printout as an IP by using;

dec_output = str(int(hex_input[0:2], 16)) + "." +  str(int(hex_input[2:4], 16)) + "." + str(int(hex_input[4:6], 16)) + "." + str(int(hex_input[6:8], 16))
  • 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-25T20:55:41+00:00Added an answer on May 25, 2026 at 8:55 pm

    If you want to get 4 separate numbers from this, then treat it as 4 separate numbers. You don’t need binascii.

    hex_input  = 'C0A80026'
    dec_output = [
        int(hex_input[0:2], 16), int(hex_input[2:4], 16),
        int(hex_input[4:6], 16), int(hex_input[6:8], 16),
    ]
    print dec_output # [192, 168, 0, 38]
    

    This can be generalised, but I’ll leave it as an exercise for you.

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

Sidebar

Related Questions

Hi I am having difficulty changing some attributes in jquery mobile dynamically for some
im having some difficulty trying to pull out a specific value from a cookie.
I am having some difficulty writing a function that will search through a directory
I am having some difficulty accessing the value of the selected radio button in
I'm having some difficulty writing some Unit Tests to test a custom ModelBinder that
I'm having some difficulty with my Entity Framework context that is proving very troublesome
I've been having some difficulty in understanding the source of a problem. Below is
I'm having some difficulty figuring out the best ways to pause and resume my
I'm having some difficulty figuring out what is going on and how to fix
I am having some difficulty creating a bundle for my application, and placing files

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.