The TKID Story

"So where does your ID number come from?" The common answers to this question are fairly simple. Some combination of birthdates, Star Wars trivia, or words spelled on telephone keypads. I decided to make it a little more complicatated...

The Algorithm

Take a text file, compute the SHA-1 hash of it, then mod (calculate the remainder after division) that value by 104. This produces a number between 0 and 9999. Since the modulo operation is greatly compressing the hash (160 bits to less than 14), collisions are bound to occur. The only way around the collisions is to try several text files and check if the numbers are taken.

The Implementation

I originally calculated my ID number using openssl and a Java program to do the modulus operation. I attempted to avoid collisions by producing several test files (some collisions still occurred). My final ID number, 7182, was calculated as follows:

  1. The text:

    Obviously this data is now out of date. I received a promotion recently and was married in March, but the file is consistent with my information at the time of enlistment when the TKID was calculated.
  2. In either UTF-8 or ISO-8859-1 (Latin-1) encoding the above text produces the following stream of bytes:
    78 97 109 101 58 32 83 116 101 112 104 101 110 32 66 97 115 104 10 68 79 66 58 32 49 57 55 57 45 49 50 45 48 56 10 82 97 110 107 58 32 67 111 109 109 97 110 100 101 114 10 72 111 109 101 119 111 114 108 100 58 32 69 97 114 116 104 10 68 101 103 114 101 101 58 32 66 83 65 65 69 10 70 105 97 110 99 101 101 58 32 73 68 45 49 50 55 57 10
  3. The bytes are fed into the SHA-1 algorithm to produce the following digest (hash):
    8341c12822752880777638977903f9c4c706246e
  4. which modulo 10,000 is:
    7182

I'm about halfway through implementing this process in a Java applet for others to play around with. When that's done, a link will be placed here.

This page last modified 07/26/07