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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:01:57+00:00 2026-05-17T19:01:57+00:00

I have strange problem when using at() method of std::string. I’d like to calculate

  • 0

I have strange problem when using at() method of std::string. I’d like to calculate md5 hash for given string using this library: http://sourceforge.net/projects/libmd5-rfc/files/
Hash is calculated correctly, but there is a problem with printing it human way. The output is:

af04084897ebbf299b04082d105ab724
ffffffaf040848ffffff97ffffffebffffffbf29ffffff9b04082d105affffffb724

Code is:

  #include <stdio.h>
  #include<string>
  #include<iostream>

  extern "C" {
      #include "md5.h"
  }

  int main()
  {
      md5_state_t state;
      md5_byte_t digest[16];

      std::string callid("f83bc385-26da-df11-95d5-0800275903dd@pc-archdev");

      md5_init(&state);
      md5_append(&state, (const md5_byte_t*)callid.c_str(), callid.length());

      std::string callid_digest((const char*)digest, 16);

      for(int i = 0; i < 16; ++i) {
          printf("%02x", digest[i]);
      }

      printf("\n");

      for(int i = 0; i < 16; ++i) {
          const char c = callid_digest.at(i);
          printf("%02x", c);
      }

      printf("\n");
  }

Where do the “f” characters come from ?

  • 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-17T19:01:57+00:00Added an answer on May 17, 2026 at 7:01 pm

    Your byte values are being sign-extended.

    That happens when you promote the (signed) char to a wider type and the top bit is set, because it tries to preserve the sign (which is why you’re seeing the extra f characters only for values greater than 0x7f). Using an unsigned char should fix the problem:

    const unsigned char c = callid_digest.at(i); // may need to cast.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem. I do this query in a node.js server using
I've got this strange problem using py-amqp and the Flopsy module. I have written
I have problem with using dequeueReusableCellWithIdentifier method. Whenever I use this one, one cell
I have an strange problem using two borders. I use them to display video
I have a very strange problem with using geometry shaders. I made a very
I do have a strange focus problem when using a JComboBox inside an embedded
I have strange problem with receiving data from socket. On client im using air
I have a strange problem with lxml when using the deployed version of my
I have a strange problem. I am using the null layout for a window
I have run into a strange problem on Android , using jQuery mobile and

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.