Algorithm to create unique value of characters
Is there some algorithm to somehow encrypt characters into a single value for later comparison with other character sequence with the same length?
no duplicates allowed: f.e. [a,b,c] = X, where X is the result of some operation to make those characters unique.
Adding up all ascii values doesn't work: [d = 100, e = 101] and [c = 99, f = 102]. Obviously both add up to 201 with different letters.
Is there an algorithm with some operations that would make that value unique?
Thanks!
marbles
Re: Algorithm to create unique value of characters
SHA1 is one algorithm that might work for you.
Viggy
Re: Algorithm to create unique value of characters
Quote:
Originally Posted by
marbles
Is there an algorithm with some operations that would make that value unique?
Why not just store the characters as a string. It's a single value and it's unique.
Re: Algorithm to create unique value of characters
Quote:
Originally Posted by
nuzzle
Why not just store the characters as a string. It's a single value and it's unique.
The problem is that the order doesn't matter: [a,b,c] and [b,c,a] should result in the same value. I tried generating all permutations and compare with a given string. But that gets huge the more characters there are.
Thanks
Re: Algorithm to create unique value of characters
Quote:
Originally Posted by
marbles
The problem is that the order doesn't matter: [a,b,c] and [b,c,a] should result in the same value.
Just sort the strings. Then both [a,b,c] and [b,c,a] will turn out [a,b,c] and be equal.