<p>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.</p>

<p>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.</p>

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:
```
```
#include <cctype>

char *safe_url(const char *str) {
    char *safe = strdup(str);
    for (int i = 0; i < strlen(str); i++) {
        if (isalpha(str[i]))
            safe[i] = str[i];
        else
            safe[i] = '_';
    }
}
```
```