I've had an idea about storing parts of SHA256 hashes and I'd like to find out how secure it is, or how much less secure it is than storing the entire hash.

For example, users can share this list of truncated hashes and each user only stores one of the entire hashes, they only need to store they're own hash, and when someone gives them a hash they don't recognize they can check it against my list.

If I have some hashes like this:

etc ...

Instead of storing all 256 bits of each hash, I'd like to store random chunks of each hash. The first step is to add a number to the end of the hash.


And now instead of storing the entire hash, I store two bytes from each hash. The first byte is byte 4 for the first hash, 7 for the second etc ... using the number I added to the end of the hash.

The first number is the 4th byte.
The second number is (first number + half size of the entire hash) % (size of the entire hash).

So based on my first hash above:

byte1 = 4th byte = 12
byte2 = (4 + 32/2) % 32 = 20th byte = F8

So instead of storing:


I could store:


So now I have my hash and if I want to compare it against the list I just check the 4th and 20th bytes equal 12 and F8, respectively.

I don't know anything about Cryptography really, so I'm wondering if this idea already exists, if it's secure and if there's a way prove mathematically how secure only storing 8 bits of the 256bit hash is as opposed to storing the entire thing.


  • 2
    $\begingroup$ It's difficult to tell whether this is “secure” since you don't tell us what security properties you expect (although like kelalaka I don't see how 16 bits can be secure for anything). Why do you want to store a tiny part of some hashes? Why do you take random parts? Why do you combine parts of several hashes together? What are you trying to do? $\endgroup$ – Gilles Dec 9 '18 at 23:29

If I understood correctly, instead of storing the full hash value, you just store 2-byte. As always, we assume that the attacker has the random chunk information, too.

It will be very easy to find a collision since your truncated hash contains only $2$-byte $= 16$-bit. By the birthday attack on hash functions, the attacker only needs to try $\sqrt{2^{16}}= 2^8 = 256$ different files to has a collision with 50% probability.

You can also see this questions and answers for truncated hash values;


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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