Hashing a 10 digit number to a 2 digit alphanumeric
I need a function that does the following:
1. Takes a 10 digit number as input and creates a unique hash of that number
2. The hash should allow letters so that it can be shorter than the original number
3. The algorithm should be one-way (ie. irreversable)
4. I'm guessing by adding 26 letters (A to Z) with (0 to 9) will give 36 possibilities for each character. This means a 10 digit number can be hashed to a 2 digit alpha-numeric (?)
10^10 = 10000000000
2^36 = 68719476736
Eg. Hash(0374863796) returns A3 and no other 10 digit number (or < 10 digits) should produce A3.
Does anyone have any ideas about the algorithm to do such a thing. I've looked over the Net at hashing algs such as MD5, but it's not really suited for my purpose. I'm afraid I'm not much good at maths either...
Re: Hashing a 10 digit number to a 2 digit alphanumeric
Quote:
Originally posted by headkaze
I need a function that does the following:
1. Takes a 10 digit number as input and creates a unique hash of that number
3. The algorithm should be one-way (ie. irreversable)
These two points appear to be at odds - at least in my opinion.
Unique means that there is only "one" new pattern for every "original" values.
One-way means that many different "original" values become the same "new" pattern. That is how "one-way" is implemented - by having many "originals" flow into a single "new" pattern. That makes it impossible to reverse...