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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:53:58+00:00 2026-06-01T18:53:58+00:00

I’m currently working on a project to convert a Python 3.2 program to C#.

  • 0

I’m currently working on a project to convert a Python 3.2 program to C#.

In the python program there’s a line of code which returns a string object of double length, containing only hexadecimal digits.

The bit of code in the Python program is:

if sha1.hexdigest().upper() == hash_string:
    #do whatever

I’ve been trying and failing to find an equivalent in C# of hexdigest from the hashlib in python.

In C# I’ve already got the SHA1 hash in a byte array but all the methods I’ve tried to carry out an equivalent of hexdigest have failed to provide a match to the hash_string – which is what the hexdigest of sha1 should match.

I’m not sure whether the problem is the method I’m using to emulate hexdigest or the method I use to generate the sha1 hash in the first place – so it’d be brilliant if anyone had a hexdigest method which they know works as that’d allow me to eliminate at least one possible cause of the problem.

The method I’m using at the moment in place of hexdigest is:

string hexaHash = "";
foreach (byte b in sha1result)
{
    hexaHash += String.Format("{0:x2}", b);
}
string result = hexaHash;

EDIT: facepalm okay, I just worked out what my problem was. When generating the sha1 hash in the python it was doing it from a lower case hex string. In my C# it was an upper case hex string. So I’d guess that the hexdigest equivalent I’m using is fine as it is. Sorry for wasting people’s time.

  • 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-01T18:54:00+00:00Added an answer on June 1, 2026 at 6:54 pm

    Use the HMACSHA1 class to convert it.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
i got an object with contents of html markup in it, for example: string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me 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.