By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Generate a unique receipt number

P: n/a
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page
that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.

I have been experimenting with classes in thue System.Security.Cryptography
namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can't have a string that is globally unique and shorter than a GUID.
Why would they make GUIDs so long if they didn't need to be? Fed Ex
tracking numbers aren't globally unique and it sounds like you don't really
need something that is unique like a guid is unique.

You could generate a random number between 1 and 36 and use that number as
an index into an array of A-Z and 0-9. Do that 10-12 times and you'll have
a fairly unique string. You could keep a database of the previously
generated strings to compare against. If on the rare occassion, you
generate one that was already used, you just generate another one.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1v*****************************@40tude.net...
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.
I have been experimenting with classes in thue System.Security.Cryptography namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #2

P: n/a
You can't have a string that is globally unique and shorter than a GUID.
Why would they make GUIDs so long if they didn't need to be? Fed Ex
tracking numbers aren't globally unique and it sounds like you don't really
need something that is unique like a guid is unique.

You could generate a random number between 1 and 36 and use that number as
an index into an array of A-Z and 0-9. Do that 10-12 times and you'll have
a fairly unique string. You could keep a database of the previously
generated strings to compare against. If on the rare occassion, you
generate one that was already used, you just generate another one.
"Chris Dunaway" <dunawayc@_lunchmeat_sbcglobal.net> wrote in message
news:1v*****************************@40tude.net...
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the application.

My requirements are these:

1. The receipt number must be unique (like a guid is unique)
2. The receipt must be NON sequential.
3. If possible, I'd like it to be 10 to 12 characters long.
4. If possible, I'd like to include only uppercase letters/digits (A-Z,
0-9)

The reason I want the length to be somewhat short is because I don't want
to burden the customer with a long receipt number. There may be a web page that allows the customer to "track" the job and I don't want them to have
to enter some really long string.

What I'm looking for is similar to a fedex tracking number. These seem to
be non-sequential and must be unique. They are about 10 to 12 digits long.
I have been experimenting with classes in thue System.Security.Cryptography namespace as well as the various hash routines but haven't, as yet,
disconvered the "magic bullet".

Can anyone push me in the right direction?

Thanks,

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.