22

If a hash algorithm has an option for selecting the output-hash-length (e.g., 128 vs. 512 bits), and all other aspects of the hash function are the same, which hash-length is probably more secure/useful, and why?

rpach17
  • 345
  • 2
  • 3
  • 9
    "more secure" does not necessarily mean "more useful". – pipe Apr 17 '17 at 23:41
  • 1
    For what kind of purpose ? Passwords, files, others ? – Walfrat Apr 18 '17 at 07:29
  • 7
    Infinite hash length provides infinite security (and zero usefulness). – Dmitry Grigoryev Apr 18 '17 at 10:37
  • 3
    zero length hashes provides no security and zero usefulness :) – Viktor Mellgren Apr 18 '17 at 13:55
  • 2
    @DmitryGrigoryev I have an infinite-length hash: encode the file size as a 7+1-bit number, where the presence of the +1 bit means that the size contains another byte in the same 7+1-bit format. After the file size is the file contents, then is an infinite checksum. This has zero security if the database is breached in addition to zero usefulness, and being an infinitely big burden! :-) – wizzwizz4 Apr 18 '17 at 18:22
  • 1
  • Which specific hash function are you working with? The answer may depend on the choice of hash function. For some hashes, increasing the length doesn't increase security to any meaningful degree. 2. We can't tell you what is more useful without more detail than is currently available in the question.
  • – D.W. Apr 18 '17 at 20:24
  • Depends what the hash should protect against. Longer hashes are harder for attackers, at the same time they reveal more about the Input. In a scenario where the data and hash is presented (checksum) the longer hash does not really provide more protection against malicious modification. – eckes Apr 20 '17 at 23:13