Tell me more ×
IT Security Stack Exchange is a question and answer site for IT security professionals. It's 100% free, no registration required.

Is there a way to make a 16-bit checksum of data with variable length, probably from 25 bytes to 8 KB?

The solution should be easy to implement, or should already be implemented in C++, and should be quick to evaluate.

share|improve this question
1  
This question should probably be in stackoverflow, or math? Anyhow, check out CRC16 (en.wikipedia.org/wiki/Cyclic_redundancy_check) – Dog eat cat world Jun 19 '12 at 8:23
2  
Hi bob - the way this, and your associated question, are written don't seem very on-topic here, where we aim to look for the most appropriate security solution/process etc for a security professional. Implementation of a piece of code should probably be in SO. Can you clarify the question - we can then see if it should be migrated in order to get answers useful for you. – Rory Alsop Jun 19 '12 at 10:27
16 bits can easily be broken by brute force. What are your security requirements? Are you really hoping to protect against malicious modification and not just low-probability random corruption? – Gilles Jun 19 '12 at 15:47

closed as off topic by Gilles, Rook, Rory Alsop Jun 19 '12 at 19:08

Questions on IT Security Stack Exchange are expected to relate to IT security within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Anything that is only 16 bits in size isn't going to be strong enough for any security application. Therefore, a non-cryptogrpahic hash function, such as CRC-16, should be fine.

If you care about security, then the minimum would be a 128-bit hash function. MD5 is 128 bits, but it's very broken, SHA-1 is 160 bits and is "safe". SHA-256 is a great choice as a security checksum.

share|improve this answer
No it's not for security in the sense that it's not used as a signature or something like that, but I asked it here because I assumed you would know that better than developers or mathematicians. I don't require the value from which the hash came from to be hard to find. It should be of length 16b. Is CRC-16 adapted for data from 25 to 8K bytes ? Does it uniformly spread the hashed values in the 16bits, so that no value is more likely to be returned than another ? Where can I find its c++ implementation ? – bob Jun 19 '12 at 8:38
@Rook - I would say that while SHA-1 is less broken then MD5 it still has its problems. There are better solutions SHA-256 for instance you should use. – Ramhound Jun 19 '12 at 11:07
1  
@bob - You are getting into a Stackoverflow question if your asking for an actual implementation in C++. – Ramhound Jun 19 '12 at 11:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.