Alright, I have some data that I need to assign an int type identifier to dynamically.
For example, here's a sample record.
<Listing>
<sportcode>AA</sportcode>
<lgabbr>NL</lgabbr>
<division>CENTRAL</division>
...
<Listing>
There is more data associated with this listing but these are the only fields that I can use to generate the identifier, and I have to use all of them.
How can I put these together to create a UNIQUE identifier?
The only idea I've had so far is to concat the the strings together and then replace each char with it's charcode. This works just fine when I'm encoding just the sportcode (AA = 6565), or sportcode and lgabbr (AANL = 65657876), but when I add division the ID becomes long and unwieldly (AANLCENTRAL = 6565787667697884826576).
Any suggestions on how to make this more consise while still being completely unique?
Edit
Several answers have been submitted that showed how to reverse the process. I think I should mention the process doesn't need to be reversible at all. Once the number is generated, that is the value that is used by the rest of the application.
Edit again I've decided to go a different way with my solution, although I got some good suggestions. Since the most efficent way to assign the identifiers is to pick them myself instead of generating them, I added an XML doc with the id defenitions and they're corresponding data. Now the XSLT stylesheet I'm using to create the identifiers can do a lookup in the attached sheet and use the identifiers I assigned. I didn't want to custom define everything because there are so many posibilities. There are roughly 25 sportcodes, 10/15 lgabbr, and 10 divisions possible. That's a lot to account for in a stylesheet. Adding the extra XML document consolidates this data outside the stylesheet for easy editing and that is the approach I'm going with (and it works BTW).
Thanks for all your suggestions.