Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dennisgaudenzi
Starting Member
26 Posts |
Posted - 2011-11-19 : 09:24:37
|
Hi everyone.I am developing an app and I can trying to figure out a way to create a unique identifier that is smaller than a normal guid. I need to display this to the customer as a tracking link, the normal sized guid is just too long to display as per my application's specs.I know I can create a uniqueidentifer field, but looking for another idea on creating maybe a 10-12 alpha-numeric unique code.Any help would be greatly appreciated!!Thank you in advance :).Dennis |
|
dennisgaudenzi
Starting Member
26 Posts |
Posted - 2011-11-19 : 09:29:05
|
Sorry, forgot to mention that I do not want to use a normal INT identity field since I do not want to show the user my data that I am using across my tables. This smaller unique ID is referenced by a int identity field for my joins. Just wanted to clarify, thanks! Dennis |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-11-19 : 13:03:37
|
Maybe use a timestamp column and present that -- without the 0x. That would be 16 characters though.Or you could use any number of hashing algorithms.Or you could just show 'em the actual tracking #. Your obfuscation isn't going to slow down a good cracker/hacker for very long if that's what you're worried about. |
|
|
dennisgaudenzi
Starting Member
26 Posts |
Posted - 2011-11-19 : 15:29:58
|
We came up with what I think will be a solution for anyone else that may have this issue in the future. We are going to use the IDENTITY field for the record and create a letter/number assigner function. For example, 1's might equal R, 2's might equal 7's, etc. Then just pad the remaining number of characters (up to the desired character length) using a random number of that length with the same function. It is always unique since once assigned to numbers, the letters/numbers would not change and not too easy to crack (we really do not care about someone cracking the code, just do not want to give the public access to what our back end data looks like).Thanks for the input Russel!Dennis |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-11-20 : 00:49:27
|
May be the same as you are doing, but we have an identity column where we don't want people to be able to guess "other peoples data" by the ID.We add a column to the table and store 6 characters (can use longer/shorter depending on requirements) from a NewID() GUID.The database retrieval routine requires both the ID and the 6-character-reference, and is thus not "guessable". We concatenate the two, so the last 6 characters is the "validator", and the other leading digits is the ID (which is just a sequential number) |
|
|
|
|
|
|
|