I’m writing a simple C++ class in which I would like cache picture thumbnails versions of images downloaded from the web. As such, I would like to use a hash function which takes in URL strings and outputs a unique string suitable as a filename.
Is there a simple way to do this without re-writing the function myself? I searched around for a simple library, but couldn’t find anything. Surely this is a common problem.
A simpler approach is to replace everything which is not a character or a number with an underscore.
EDIT: Here’s a naive implementation in C: