473,322 Members | 1,494 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,322 software developers and data experts.

Random numbers, seeds

Hi,

Each instance of my client application will generate a 15 character
random string the first time it is run. This unique string will be used to
identify the client from that point forward. It's essential that no two
clients have the same identification string.

The random characters in the identification string are generated using
the Random class which is seeded with the current DateTime. The problem is
that it's conceivable that two clients (either on two separate machines or
on two different terminal sessions on the same machine) could generate their
IDs at precisely the same time which would lead to generation of the same 15
character ID.

Is there a better choice of a seed value that would generate numbers
that have less chance of duplication? The only foolproof method that I can
think of is to have the clients request their IDs from the server. The
server would then be generating the IDs via a single instance of the Random
class which would guarantee (practically) uniqueness.

--
Sincerely,

David Sworder
http://www.CodeFanatic.com
Nov 22 '05 #1
1 1320
Why you don't want to use GUIDs?
Anyway, you should take a look at RNGCryptoServiceProvider class.

HTH
Alex

"David Sworder" <ds******@cts.com> wrote in message
news:eK**************@TK2MSFTNGP11.phx.gbl...
Hi,

Each instance of my client application will generate a 15 character
random string the first time it is run. This unique string will be used to
identify the client from that point forward. It's essential that no two
clients have the same identification string.

The random characters in the identification string are generated using
the Random class which is seeded with the current DateTime. The problem is
that it's conceivable that two clients (either on two separate machines or
on two different terminal sessions on the same machine) could generate their IDs at precisely the same time which would lead to generation of the same 15 character ID.

Is there a better choice of a seed value that would generate numbers
that have less chance of duplication? The only foolproof method that I can
think of is to have the clients request their IDs from the server. The
server would then be generating the IDs via a single instance of the Random class which would guarantee (practically) uniqueness.

--
Sincerely,

David Sworder
http://www.CodeFanatic.com

Nov 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Trythat | last post by:
This might seem a stupid question but here goes - I wrote a key generator for one of my programs in Visual Basic, so I recieve sales notification via email and then use my program to generate the...
3
by: Joe | last post by:
Hi, I have been working on some code that requires a high use of random numbers within. Mostly I either have to either: 1) flip a coin i.e. 0 or 1, or 2) generate a double between 0 and 1. I...
70
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like...
11
by: Mark Rae | last post by:
Hi, My R&D department has asked me to look at threading in a Web Service written in C#, so I came up with the following code: using System; using System.ComponentModel; using...
10
by: Marshall Belew | last post by:
I'm trying to synchronize a network app that uses random numbers generated by System.Random. Rather than pass every randomly generated number, I just pass the seed. I'm seeing a result that leads...
104
by: fieldfallow | last post by:
Hello all, Is there a function in the standard C library which returns a prime number which is also pseudo-random? Assuming there isn't, as it appears from the docs that I have, is there a...
13
by: porterboy76 | last post by:
If you only use a 32 bit seed for a random number generator, does that mean you can only ever produce a maximum of 2^32 (approx 4 billion) different sequences? What about the Mersenne Twister,...
6
by: Intiha | last post by:
Hello all, I am trying to generate random seeds for my simulations. currently i was using srand(time(NULL); for this purpose. But for confidence in my results i ran it using a script in a loop....
3
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new...
8
by: Daniel | last post by:
Hey guys Using Random(), how random is it, is it possible to be predicted? I have a requirement for a very good random number generator. I was doing something such as: Random randomSeed = new...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.