|
|
Hello
In my project I need a checksum algorithm that never produce zero.
I am wondering if there is one!
SignatureNotFoundException
|
|
|
|
|
None that I know of: zero is normally a valid result in all systems.
About the best I can think of is that you add data to the checksum: maybe convert it to hex digits, so a zero checksum would produce "00" instead of '\0'
Why on earth do you think you need this?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Why on earth do you think you need this?
I'm guessing the thinking is if the checksum byte/word... is zero then it's not a checksum - OIOW a lazy way to check for the presense of a checksum (albeit not the correctness).
Signature ready for installation. Please Reboot now.
|
|
|
|
|
I'm guessing that he's trying to use strings instead of byte arrays, and doesn;t want a zero as a null terminator - in which case he has some much bigger problems coming ...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There are checksums that can result in 0 but not in 65535 (or 232-1, if you need it that big). Add 1.
|
|
|
|
|
Or string concat (prefix) a 1 or any other number to the left of the generated checksum. (would potentially need a bigger db column type)
|
|
|
|
|
Follow up question. Is there one that doesn’t produce a result of “10”?
I'm pretty sure I would not like to live in a world in which I would never be offended.
I am absolutely certain I don't want to live in a world in which you would never be offended.
Freedom doesn't mean the absence of things you don't like.
Dave
|
|
|
|
|
+5 for the best and most simple solution.
Jeremy Falcon
|
|
|
|
|
I can already see tomorrows question in the lounge:
"Is there any checksum algorithm that does not produce 65535?"
|
|
|
|
|
Plz send codez. I need a checksum algorithm that always produces 42!
... such stuff as dreams are made on
|
|
|
|
|
uint Hash(byte[] data)
{
uint result = 0;
if (data == null)
return result;
uint MAX = uint.Max - 1;
for (int i=0; i<data.Length; i++)
result = 1 + ((result << 8 + result >> 24) | data[i]) % MAX;
return 42;
}
|
|
|
|
|
The modulus algo I've experienced return X if the remainder is 0
We can’t stop here, this is bat country - Hunter S Thompson RIP
|
|
|
|
|
uint Hash(byte[] data)
{
uint result = 0;
if (data == null)
return result;
uint MAX = uint.Max - 1;
for (int i=0; i<data.Length; i++)
result = 1 + ((result << 8 + result >> 24) | data[i]) % MAX;
return result;
}
|
|
|
|
|
This is the type of cryptography thinking that allowed us to break the Enigma code
|
|
|
|
|
int CalculateChecksum() {
return 1;
}
|
|
|
|
|
xkcd: Random Number[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello, and I apologise if this question has been asked a billion times already. I just remembered I used to code for a living, and was idly wondering if that huge ...um... "mistake" has been fixed yet.
You know the one, where everyone has now moved on to fast but small SSD's and MS wants to dump about 50Gb of stuff on your C: drive, no options, so suck it up.
I actually quit programming because of that and now wear steel-cap boots and a hi-viz vest to make ends meet.
But I want to return to the stuff I love the most - coding.
Yup, I could choose another platform and IDE, but I don't want to.
Is there any hope?
|
|
|
|
|
Well, SSDs have grown in size and a 500 GB is within reach for most folks. The drive space that VS 2017 requires varies, depending on which features you install. I installed it for C# + WPF as well as UWP apps. It took about 8GB of my 500 GB Samsung SSD - virtually negligible.
I can highly recommend going for an SSD, as it just runs so much faster. I would not bother with any IDE other than Visual Studio 2017. And keep in mind the fully functional Community Edition is completely free.
Get me coffee and no one gets hurt!
|
|
|
|
|
You beat me to it! (I had to lookup vs 2017 typical footprint)
I really need to get with the times and move on from VS 2010. I use 2015 for a few projects, but dislike it due to load times/resource consumption. One of my new year resolutions is to install and start using 2017 instead of 2010/2015...figured the kinks should be worked out by now.
Enjoy your weekend!
"Go forth into the source" - Neal Morse
|
|
|
|
|
I have used VS 2010, 2012 and now 2017. The latter is by far my favorite. I did try 2013 for a short while, but did not like it. 2017 rocks!
Oh: Have a great weekend yourself!
Get me coffee and no one gets hurt!
|
|
|
|
|
Plus VS2017 2nd latest update has project load on demand, so it doesn't take all week and load each project in the solution on startup, but it only loads a project when you want to debug or work on it.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
I disabled this. Found that when performing a search across the solution, it had to wait for everything to load. I'll take the hit from my SSD and have the whole solution ready to work.
Hogan
|
|
|
|
|
Aaah, yes, I suppose I never noticed that because my solutions are normally very small, and it doesn't unload projects, so I probably only ever do a solution wide search once all projects are loaded.
I don't have the luxury of an SSD so I wait ages even for small solutions to load all projects.
"'Do what thou wilt...' is to bid Stars to shine, Vines to bear grapes, Water to seek its level; man is the only being in Nature that has striven to set himself at odds with himself."
—Aleister Crowley
|
|
|
|
|
Mostly, everyone has moved on to SSD's due to increased capacity at a lower cost. Currently, you can get a 480GB SSD for < $150 USD. You don't have to worry about a license for VS anymore, so get VS 2017 CE and forget about the 20-50GB it's going to occupy. btw, welcome back to coding!
"Go forth into the source" - Neal Morse
|
|
|
|