language for random number generator

Networking/Security Forums -> Programming and More

Author: flwLocation: U.S.A. PostPosted: Mon Feb 03, 2003 5:33 am    Post subject: language for random number generator
    ----
I'm playing with a routine and I need to have a random number generator that can use the date and time to create the random number. Therefore the pattern could never be duplicated easily without the exact date and time to the second of the computation.

What language(s) can use both date and time together?

Author: myhatisred PostPosted: Mon Feb 03, 2003 5:36 am    Post subject:
    ----
for what platform?? almost any language can do that. I'd say C/C++ would be the easiest

Author: WombatLocation: Canberra PostPosted: Mon Feb 03, 2003 6:50 am    Post subject:
    ----
A lot of languages already have a function to generate random numbers from date and time, just like you need. In Visual Basic the random number generator function is Rnd(), and there's also the Randomize statement to reset the generator's seed to the current system date/time.

Last edited by Wombat on Mon Feb 03, 2003 11:41 pm; edited 1 time in total

Author: flwLocation: U.S.A. PostPosted: Mon Feb 03, 2003 3:00 pm    Post subject:
    ----
It was my understanding that most were set by time and not by date as well. Is this incorrect?

Also some are coded so that they are closer to being random than others.
Is this incorrect?

Thanks

Author: myhatisred PostPosted: Mon Feb 03, 2003 3:38 pm    Post subject:
    ----
most of the high-level languages are completely random #s there's no formula to really figure them out.

Author: flwLocation: U.S.A. PostPosted: Mon Feb 03, 2003 8:31 pm    Post subject:
    ----
Quote:
most of the high-level languages are completely random #s there's no formula to really figure them out.


Which is why my quesiton is which languages will or already do use date as well as time for generation. i.e. It is my understanding that java just uses time only. This may be wrong but that's why I'm asking.
[/quote]

Author: myhatisred PostPosted: Mon Feb 03, 2003 8:39 pm    Post subject:
    ----
I'm almost positive that C/C++ uses date and time

Author: decypherohmLocation: World - Europe - Portugal - Lisbon PostPosted: Mon Feb 03, 2003 11:32 pm    Post subject:
    ----
Is there any randomizer for pascal?!?!?!

Author: myhatisred PostPosted: Mon Feb 03, 2003 11:35 pm    Post subject:
    ----
i don't know pascal but there's some sort of random # generator for all languages

Author: WombatLocation: Canberra PostPosted: Mon Feb 03, 2003 11:41 pm    Post subject:
    ----
I had a dig through MSDN and it turns out that by default Visual Basic uses the number of seconds elapsed since midnight as the seed. Not as random as I would have liked!

However, you can choose to give the
Randomize statement a number to use as the seed. You could easily add the current system date and time to use as the seed. This would probably give you what you want:

Code:
Dim MySeed
Dim MyRandomNumber

MySeed = Date + Time
Randomize MySeed
MyRandomNumber = Int((100 * Rnd) + 1)   ' Generates random value between 1 and 100.

Author: ToddKLocation: Ottawa, Canada PostPosted: Tue Feb 04, 2003 12:34 am    Post subject:
    ----
VB's random is pretty non-random. Totally sucky.

A good method is to use a GUID.

Author: vlad902 PostPosted: Tue Feb 04, 2003 2:19 am    Post subject:
    ----
OpenBSD for true random ness! Laughing Best way I say to make a random number is to multiply a couple of random numbers, then multiply them by the time and date (so if it's 4:22 it's multipled by 4 and then 22) and that will make it pretty god damn random Very Happy

Author: tutaepakiLocation: New Zealand PostPosted: Tue Feb 04, 2003 2:36 am    Post subject:
    ----
http://triumvir.org/rng/

For lots of links to discussions of Random numbers and some of their
dubious randomness. It includes plenty of samples too.



Networking/Security Forums -> Programming and More


output generated using printer-friendly topic mod, All times are GMT + 2 Hours

Page 1 of 1

Powered by phpBB 2.0.x © 2001 phpBB Group