| Topic List |
Page List:
1 |
|---|---|
|
Yellow 07/26/24 9:53:35 PM #1: |
In my software I have a huge structure of data, maybe upwards of a GB. I eventually have to check the hash/checksum of this data, by reading the entire thing over again. However; what if I want to not have to re-read the entire thing to get that hash? What if I just want to update one item and update the hash accordingly? Just writing this I came up with some idea on how to do this, but I'll see if anyone can think of a better solution. Here is the hash method I'm using, btw. It's called a Knuth hash. For those who don't read code, I'm adding the value to 3,074,457,345,618,258,791, and then multiplying that value by 3,074,457,345,618,258,791, for each byte in the data. ulong hashedValue = 3074457345618258791ul; for (int i = 0; i < span.Length; i++) { hashedValue += span[i]; hashedValue *= 3074457345618258799ul; }--- https://www.youtube.com/watch?v=5C_Wrt6pNSw ... Copied to Clipboard!
|
|
Yellow 07/26/24 10:54:15 PM #2: |
Solution below, don't read, figure it out! I have an unfair advantage because I work with these things all the time. Fun fact 03074457345618258791 is the largest prime number that will fit in the long max value 18446744073709551615 I found an old list replacement class I wrote 3 years ago that I can upgrade with this functionality https://github.com/jamieyello/NoDb/blob/master/SlothSerializer/Internal/LowMemList.cs I knew it would be useful one day. ( 0:50 ) https://youtu.be/mGGFBycv2Hs?si=6e63EP4ZjbjZTH7N&t=50 --- https://www.youtube.com/watch?v=5C_Wrt6pNSw ... Copied to Clipboard!
|
| Topic List |
Page List:
1 |