• RSS
  • Twitter
  • FaceBook

Security Forums

Log in

FAQ | Search | Usergroups | Profile | Register | RSS | Posting Guidelines | Recent Posts

language for random number generator

Users browsing this topic:0 Security Fans, 0 Stealth Security Fans
Registered Security Fans: None
Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More

View previous topic :: View next topic  
Author Message
flw
Forum Fanatic
Forum Fanatic


Joined: 27 May 2002
Posts: 16777215
Location: U.S.A.

Offline

PostPosted: Mon Feb 03, 2003 5:33 am    Post subject: language for random number generator Reply with quote

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?
Back to top
View user's profile Send private message Visit poster's website
myhatisred
Just Arrived
Just Arrived


Joined: 11 Jan 2003
Posts: 0


Offline

PostPosted: Mon Feb 03, 2003 5:36 am    Post subject: Reply with quote

for what platform?? almost any language can do that. I'd say C/C++ would be the easiest
Back to top
View user's profile Send private message Visit poster's website AIM Address
Wombat
Trusted SF Member
Trusted SF Member


Joined: 24 Apr 2002
Posts: 0
Location: Canberra

Offline

PostPosted: Mon Feb 03, 2003 6:50 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
flw
Forum Fanatic
Forum Fanatic


Joined: 27 May 2002
Posts: 16777215
Location: U.S.A.

Offline

PostPosted: Mon Feb 03, 2003 3:00 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
myhatisred
Just Arrived
Just Arrived


Joined: 11 Jan 2003
Posts: 0


Offline

PostPosted: Mon Feb 03, 2003 3:38 pm    Post subject: Reply with quote

most of the high-level languages are completely random #s there's no formula to really figure them out.
Back to top
View user's profile Send private message Visit poster's website AIM Address
flw
Forum Fanatic
Forum Fanatic


Joined: 27 May 2002
Posts: 16777215
Location: U.S.A.

Offline

PostPosted: Mon Feb 03, 2003 8:31 pm    Post subject: Reply with quote

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]
Back to top
View user's profile Send private message Visit poster's website
myhatisred
Just Arrived
Just Arrived


Joined: 11 Jan 2003
Posts: 0


Offline

PostPosted: Mon Feb 03, 2003 8:39 pm    Post subject: Reply with quote

I'm almost positive that C/C++ uses date and time
Back to top
View user's profile Send private message Visit poster's website AIM Address
decypherohm
Just Arrived
Just Arrived


Joined: 16 Nov 2002
Posts: 1
Location: World - Europe - Portugal - Lisbon

Offline

PostPosted: Mon Feb 03, 2003 11:32 pm    Post subject: Reply with quote

Is there any randomizer for pascal?!?!?!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
myhatisred
Just Arrived
Just Arrived


Joined: 11 Jan 2003
Posts: 0


Offline

PostPosted: Mon Feb 03, 2003 11:35 pm    Post subject: Reply with quote

i don't know pascal but there's some sort of random # generator for all languages
Back to top
View user's profile Send private message Visit poster's website AIM Address
Wombat
Trusted SF Member
Trusted SF Member


Joined: 24 Apr 2002
Posts: 0
Location: Canberra

Offline

PostPosted: Mon Feb 03, 2003 11:41 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
ToddK
Just Arrived
Just Arrived


Joined: 29 Nov 2002
Posts: 0
Location: Ottawa, Canada

Offline

PostPosted: Tue Feb 04, 2003 12:34 am    Post subject: Reply with quote

VB's random is pretty non-random. Totally sucky.

A good method is to use a GUID.
Back to top
View user's profile Send private message Visit poster's website
vlad902
Just Arrived
Just Arrived


Joined: 04 Jan 2003
Posts: 0


Offline

PostPosted: Tue Feb 04, 2003 2:19 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
tutaepaki
Trusted SF Member
Trusted SF Member


Joined: 02 May 2002
Posts: 3
Location: New Zealand

Offline

PostPosted: Tue Feb 04, 2003 2:36 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   

Post new topic   Reply to topic   Printer-friendly version    Networking/Security Forums Index -> Programming and More All times are GMT + 2 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Community Area

Log in | Register