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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:04:42+00:00 2026-05-26T22:04:42+00:00

I have a struct with 2 bytes inside. How to compute checksum (e.g. MD5

  • 0

I have a struct with 2 bytes inside. How to compute checksum (e.g. MD5 hash) for array of such structs?

public struct MyStruct
{
    public byte Byte1;
    public byte Byte2;
}

public class MyClass
{
    public static byte[] ComputeChecksum(MyStruct[] myStructs)
    {
        // TODO: calculation.
    }
}
  • 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-26T22:04:43+00:00Added an answer on May 26, 2026 at 10:04 pm

    So do you want STRONG digesting or just a quick error-check/consistent-lookup value?

    MD5/SHA is pretty intensive operations – they’re built around block-structures that are multiples of hundreds of bytes.

    fletcher and CRC32 are very efficient and do a decent job of producing a random number.. What they are not good at is having random bit positions.. So for example, you wouldn’t want a fletcher than only look at only the upper or bottom 8 bits (since there would be too little varience)..

    Either find an open-source library or hit wikipedia for the various algorithms.. I tend to just use something like:

      u32 hash_mystruct(mystruct[] data, u32 count) {
          return hash((u8*)data, sizeof(mystruct) * count);
      }
      u32 hash(u8* data, u32 size) {    
        u32 hash = 19;
        for (u32 i = 0; i < size; i++) {
          u8 c = *data++;
          if (c != 0) { // usually when doing on strings this wouldn't be needed
            hash *= c;
          }
          hash += 7;
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code intended to get a struct from a byte array: public
i have a structure public struct SERVER_USB_DEVICE { USB_HWID usbHWID; byte status; bool bExcludeDevice;
In my C# application, I have a large struct (176 bytes) that is passed
I have the following struct: struct Datastore_T { Partition_Datastores_T cmtDatastores; // bytes 0 to
I have a byte stream I need parsed into a struct, and I also
I have this struct: struct Map { public int Size; public Map ( int
i have this code function in C++ to convert different objects to bytes array:
I have a a struct defined thusly: typedef struct _CONFIGURATION_DATA { BYTE configurationIndicator; ULONG32
The following struct X has 3 bytes of payload and 1 byte of padding:
I'm trying to use vectors inside structs with LLVM. I have the following C

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.