String Hashing in PHP


I’ve been doing some work with Amazon’s Web Services like S3 and SimpleDB this week, and to relate records to each other, I wanted to use a hashing algorithm instead of just a string..

For speed, I decided to use a DJB2 hash as shown below:

Using this function, a string like “bacon” becomes “134152229”..

Now as to why I’m using SimpleDB for a project.. Scalability.. SimpleDB is built for scalability, and also for use across multiplte platforms.. In the case of this project, it’s being used on a couple different interfaces such as a web app, iOS app, Android app, and multiple servers, so Simple DB makes sense here for what is needed..

Filed Under: Code

Roger Stringer spends most of his time solving problems for people, and otherwise occupying himself with being a dad, cooking, speaking, learning, writing, reading, and the overall pursuit of life. He lives in Penticton, BC.

Connect: Twitter |  Google+
This content is supported by readers like you.