|
-
April 3rd, 2010, 09:37 PM
#1
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
-
April 5th, 2010, 11:11 AM
#2
Re: Algorithm to create unique value of characters
SHA1 is one algorithm that might work for you.
Viggy
-
April 6th, 2010, 02:49 PM
#3
Re: Algorithm to create unique value of characters
 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.
Last edited by nuzzle; April 6th, 2010 at 02:58 PM.
-
April 6th, 2010, 04:43 PM
#4
Re: Algorithm to create unique value of characters
 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
-
April 6th, 2010, 04:56 PM
#5
Re: Algorithm to create unique value of characters
 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.
Last edited by nuzzle; April 6th, 2010 at 05:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|