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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:37:04+00:00 2026-06-06T13:37:04+00:00

I used this link to create a SHA1 hash for any data using C++.

  • 0

I used this link to create a SHA1 hash for any data using C++. But the output buffer from SHA1 call is an unsigned char*. I want to store the hexadecimal values i.e. the Message Digest values so that I can use them for other operations.

As those are unsigned char* it doesn’t make sense in converting them to a string and then performing hexadecimal conversion. So I have to do the hex conversion and then store the values as a string or char*. How can I do this?

SHA1(ibuf, strlen(ibuf), obuf);
for (i = 0; i < 20; i++) {
        printf("%02x ", obuf[i]);
  • 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-06T13:37:05+00:00Added an answer on June 6, 2026 at 1:37 pm

    To format to a char[], use snprintf:

    char out[61]; //null terminator
    for (i = 0; i < 20; i++) {
        snprintf(out+i*3, 4, "%02x ", obuf[i])
    }
    

    Edit: I see you’ve tagged your question C++. This is a purely C solution, mostly because I don’t know C++.

    We’re using a max size of 4 because we need to include the null terminator in that count (by the function definition). We only move ahead by three specifically to overwrite the null terminator.

    The extra space at the end is bound to happen based on our format string of "%02x ", but if we special-case the last element we can use a different format string of "%02x" to avoid that.

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

Sidebar

Related Questions

I used this link http://blog.androgames.net/85/android-accelerometer-tutorial/ to create an accelerometer. But I want that this
I'm currently referring to this link to create the timer for my program. But
Hai i want create a full screen mode ,so i used this link http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/
i have a DTD file which i used to accessed through this link: http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd
I used this script to create a jQuery accordion. Check out the working jsFiddle
I used this code previously in netbeans 6.9.1 but it does not seem to
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
I am trying to create a excel file from Mysql using php. I found
Im trying to create a multilanguage website.I used this http://www.phpsimplicity.com/tips.php?id=15 tutorial and it works
I got a fingerprint 73:F9:85:F8:14:56:4A:E7:D1:D4:31:6F:23:AA:4D:38:EB:16:5C:EE but when i used to generate api Key using

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.