Found this online, hope it helps.
" In addition to a national registration number, all aircraft are assigned a unique ICAO 24-bit address or (informally) Mode-S "hex code" upon registration and this international identifier becomes a part of the aircraft's Certificate of Registration. If you have a Mode-S transponder, this code gets programmed into it, and is transmitted to identify your aircraft.
I don't know if the ICAO code is a mathematical encoding of the registration number, or if it is just randomly assigned and the only way to convert one to the other is though a database lookup.
There are 16,777,214 unique ICAO 24-bit addresses available and they may be represented in hexadecimal, octal, or binary format. Online tools such as those at Airframes.org and Kloth.net can match the aircraft's tail number to its ICAO code and return airframe information from the publicly-available FAA aircraft database.
There's more information available on Wikipedia:
http://en.wikipedia.org/wiki/Aviation_transponder_interrogation_modes
Hope this helps!
Reiff"