on a tangent, one way could be assign a number code to each alphabet. Add the numbers that occur in the strings. IF the sum matches, they are anagrams.
You’re right.
So I think something silly like: character_code = len(string)*len(alphabet)^character_index should work.
ac = 1 + 3 = 4 bb = 2 + 2 = 4
Still, consider the word ‘abe’ with a = 2, b = 3, c = 5, d = 7 and e = 11.
abe would then be 2^1 * 3^1 * 5^0 * 7^0 * 11^1. ‘abba’ would be 2^2 * 3^2. Each anagram would have a distinct value.
See also Gödel numbering and FRACTRAN.