My first thought is that you should be looking at implementations of Hamming Distance. If you are actually looking for something like SOUNDEX you might also want to look at the double metaphor algorithm, which is significantly harder to implement but provides better matching and is less susceptible to differences based on name origins.