I've needed to do this a couple of times, so I guess it's time to save it as a Gist for next time.
What I needed was a way to calculate a color based on string contents, where the same string would always generate the same color. I also wanted the colors generated to be part of the web safe palette. Not that there's any reason to stay in that palette for browsers now, but I wanted to keep the possible palette relatively small and have colors that generally look okay together. The math behind the web safe palette made it pretty easy.
As it works out, all of the web safe colors are multiples of 51. We'll need that bit of trivia in a second...