Dynamic Length Hash Function?

Sorry if this is elementary, but is there such a thing as a dynamic length (output) hash function? Something that would be a fast way to calculate hashes and output different lengths of strings for the output.

This may give away some of the length of the message, and could be undesirable for many other reasons, but would possibly avoid collisions?

• It would destroy one basic goal, to have limited length hashes for arbitrary length inputs with good collision, 1st preimage, 2nd preimage properties. I suppose you could allow a range of lengths, say 512 to 4096 bits, but it is unclear how much of an advantage this would give to a principled way of avoiding collisions. – kodlu Mar 27 '18 at 22:51
• Look into the SHAKE functions of the new SHA3. en.wikipedia.org/wiki/SHA-3 – mikeazo Mar 27 '18 at 22:53
• mikeazo is right. The set of dynamic length hash functions has been given a name too: XOF, an extendable output function. They don't give away any info on the length of the message by the way. The amount of output is decoupled from the size of the input. – Maarten Bodewes Mar 27 '18 at 23:47

But beware of the determinism of these functions, that is if you hash $m$ with them, and then take the first 256 and the first 512 bits in two different places, they will both share 256 bits!
As the names suggest, SHAKE128 aims at a 128-bit security level, meaning you'll need $2^{\min(128,d/2)}$ operations to find a collision, where $d$ is the length of the output. So why does it "only" provide 128-bit security at most? Because you can find a collision on the internal structure with $2^{128}$ operations that will result in a collision on the output stream.