|
-
Aug 15th, 2004, 02:50 PM
#1
Thread Starter
New Member
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...
-
Aug 15th, 2004, 02:56 PM
#2
Fanatic Member
I don't think you will be able to only use 2 characters and have any form of uniqueness, if you only use Alphanumeric characters you have a total of 36 characters to utilize:
So, ( 36 ^ 2 ) = 1296
That means there are only 1296 combinations of all of those characters when only 2 characters are used. No where near a 10 digit number...
-
Aug 15th, 2004, 03:02 PM
#3
Thread Starter
New Member
Oops... err as I said, my maths skills are not much to be desired.
Ok, if we correct my mistake, and make the new number 8 digits
ie. 36^8 = 2821109907456
Which should cover a 10 digit number, yes?
After I correct this ahem discrepency with my original post, are there any suggestions as to a solution to such a problem?
Thanks in advance
Last edited by headkaze; Aug 15th, 2004 at 03:08 PM.
-
Aug 15th, 2004, 04:06 PM
#4
Re: Hashing a 10 digit number to a 2 digit alphanumeric
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...
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
|