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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:19:29+00:00 2026-05-12T11:19:29+00:00

Good evening all, I’ve been working on an MD5 tool in C# that takes

  • 0

Good evening all,

I’ve been working on an MD5 tool in C# that takes a file, goes through my Hasher class and pops the result in a database, along with the filename and directory.

The issue I’m having is that each time I run the test, the MD5 result for the same identical file i.e. unchanged in any way is completely different.

Below is the code I use

HashAlgorithm hmacMd5 = new HMACMD5(); 
byte[] hash;
try
{
    using (Stream fileStream = new FileStream(fileLocation, FileMode.Open))
    {
        using (Stream bufferedStream = new BufferedStream(fileStream, 5600000))
        {
            hash = hmacMd5.ComputeHash(bufferedStream);
            foreach (byte x in hash)
            {
                md5Result += x;
            }
        }
    }
}
catch (UnauthorizedAccessException uae) { }

return md5Result;

Here are the results for 3 seperate runs of hello.mp2:

1401401571161052548110297623915056204169177

16724366215610475211823021169211793421

56154777074212779619017828183239971

Quite puzzling.
My only rational thought as to why I’m getting these results is with concatenating byte to string.

Can anyone spot an issue here?

Regards,

Ric

  • 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-12T11:19:30+00:00Added an answer on May 12, 2026 at 11:19 am

    You should use System.Security.Cryptography.MD5 rather.

    HMACMD5 doesn’t compute a hash, it computes a message authentication code.

    HMACMD5 is a type of keyed hash
    algorithm that is constructed from the
    MD5 hash function and used as a
    Hash-based Message Authentication Code
    (HMAC). The HMAC process mixes a
    secret key with the message data,
    hashes the result with the hash
    function, mixes that hash value with
    the secret key again, then applies the
    hash function a second time. The
    output hash will be 128 bits in length

    Since you’re not supplying the HMAC key, one is being generated randomly for you on your behalf and causing you to see different results.

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

Sidebar

Related Questions

Good Evening All, A client has asked that I develop a web application as
Good Evening All, I have a textbox that needs to accept 14 digits plus
Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add
Good evening, I am developing a set of Java classes so that a container
Good evening everyone! I am working on learning some java and I have made
Good evening. I found a few questions that seemed to ask the same thing
Good evening all. I'm attempting to dynamically populate a select_tag call in my rails
Good evening, I am tired and have been fighting with this for hours. I
Good Evening everyone, I've been trying to figure out the most efficient way to
Good evening I've got a little problem with my DataGridView in a .NET Windows

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.