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

The Archive Base Latest Questions

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

For instance, I do an MD5 of hashable using: protected string hexHashMD5(byte[] filePart) {

  • 0

For instance, I do an MD5 of “hashable” using:

        protected string hexHashMD5(byte[] filePart) {
        // Now that we have a byte array we can ask the CSP to hash it
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] result = md5.ComputeHash(filePart);

        // Build the final string by converting each byte
        // into hex and appending it to a StringBuilder
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < result.Length; i++) {
            sb.Append(result[i].ToString("X2"));
        }

        // And return it
        return sb.ToString();
    }

and store it’s output into a string variable in my program. How can I take that Hash and add another byte[] to create a new hash?

I’ve been told that you can use file stream, to automatically stream in a bit at a time, and make the full hash, but what happens when I need to hash two separate files together?

  • 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:09:55+00:00Added an answer on May 25, 2026 at 8:09 pm

    You can make a custom Stream class that reads the two streams in order, then pass that to ComputeHash.

    Alternatively, you can read both streams one block at a time and pass each block to TransformBlock:

    byte[] buffer = new byte[4096];
    while (true) {
        int read = stream1.Read(buffer, 0, buffer.Length);
        if (read == 0) break;
        hash.TransformBlock(buffer, 0, read, null, 0);
    }
    
    while (true) {
        int read = stream2.Read(buffer, 0, buffer.Length);
        if (read == 0) break;
        hash.TransformBlock(buffer, 0, read, null, 0);
    }
    
    hash.TransformFinalBlock(new byte[0], 0, 0);
    var hashCode = hash.Hash;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For instance, I have a SqlDataSource that loads a list of items. On my
I am trying to store the md5 string as a class instance variable instead
For instance, I have a document that has a pile of control codes that
For instance, my query is like the following using SQL Server 2005: SELECT *
For instance, does the compiler know to translate string s = test + this
Using instance methods as callbacks for event handlers changes the scope of this from
I'm trying to connect to a website I made with auth that uses MD5.hex(password)
Hi I am now using spring security. It works fine. But if login failed,
I have an image upload script, and the thumbnails that its producing are posterized
Instance A is trying to restore instance B's window, but I can't get the

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.