473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Generate a unique receipt number

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
2 4492
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mullin | last post by:
I need to generate a unique no. in the format like yyyymmddxxxxxx (xxxxxx 6-digitl running number) I think of create a table with two columns date value 20050405 120 20050406 99...
10
by: Mamuninfo | last post by:
Hello, Have any function in the DB2 database that can generate unique id for each string like oracle, mysql,sybase,sqlserver database. In mysql:- select md5(concat_ws("Row name")) from...
2
by: Chris Dunaway | last post by:
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...
28
by: Nina | last post by:
I need to generate unique id for my application. Use system time to create id, which is the best fit, but I don't know how to do it. Please help. Thanks in advance for any input.
16
by: Mark S. | last post by:
I'm a fan of the GUID, but the current project is looking to use a genuinely unique integer. Does the following do that? Math.Abs(System.Guid.NewGuid().GetHashCode()) TIA
15
by: Ashish Khandelwal | last post by:
As MSDN is not giving us guarantee upon uniqueness of Hash Code, so could any one suggest me that how to generate a unique Hash Code for same string always, and generate different-2 Hash Code...
4
by: gaurav1983 | last post by:
i have to generate unique combinations of given number of digits entered by user eg: N=4 (0,1,2,3) output should be 0 1 2 3
1
by: situ | last post by:
Hi, I'm using DB2 V9 for windows I'm inserting records into DGTT from select statement; the problem is how to insert unique value for every row inserted. I tried using “generated always as”...
12
by: Ivan Popov | last post by:
I need to generate a unique serial number for each field in the table. The serial number shall consist of two letters and six numbers, for example AA123456. Someone can suggest how to do it in MS...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.