Comparing anagrams using prime numbers
Use multiplication instead of addition. Primes are "multiplicatively unique", but not "additively unique".
A slightly more clunky way to do it would require the length of your longest string max_len (or the largest number of any specific character for slightly better performance). Given that, your hash could look like
number_of_a*max_len^51 + number_of_b*max_len^50 + ... + number_of_Z*max_len^0
If you preferred to use primes, multiplication will work better, as previously mentioned.
Of course, you could achieve the same effect by having an array of 52 values instead.