Hack Forums
[.NET] ActualRand() - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] ActualRand() (/showthread.php?tid=4425355)

Pages: Pages 1 2


* - Rolex™ - Sep 1, 2014

Nothing is completely random like the others said. I would just use the built in class or if you really wanted to get as random as you could use http://Random.org. They use radio receivers to pick up atmospheric noise, which is quite "Random". If you wanted to do it, it's the simplest thing to do.

(Excuse the C# Code)
PHP Code

<?php 
using
(Webclient client = new Webclient()){

string RandomNumber = client.DownloadString("http://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new");
int Ran = int.Parse(RandomNumber);

} 
If you wanted a little more customization:
PHP Code

<?php 
public static int Randomint(int min, int max)
      {
      
using (WebClient client = new WebClient())
      {

            
string RandomNumber = client.DownloadString("http://www.random.org/integers/?num=1&min=" + min + "&max=" + max + "&col=1&base=10&format=plain&rnd=new");
             return 
int.Parse(RandomNumber);

      }
      } 

This would generate a random number between 1 -100, and would be the most efficient way to go about achieving as close to "Random" as possible.


* - tweety - Sep 1, 2014

(Sep 1, 2014 05:22 PM)Rolex™ Wrote:  Nothing is completely random like the others said. I would just use the built in class or if you really wanted to get as random as you could use http://Random.org. They use radio receivers to pick up atmospheric noise, which is quite "Random". If you wanted to do it, it's the simplest thing to do.

(Excuse the C# Code)
PHP Code

<?php 
using
(Webclient client = new Webclient()){

string RandomNumber = client.DownloadString("http://www.random.org/integers/?num=1&min=1&max=100&col=1&base=10&format=plain&rnd=new");
int Ran = int.Parse(RandomNumber);

} 
If you wanted a little more customization:
PHP Code

<?php 
public static int Randomint(int min, int max)
      {
      
using (WebClient client = new WebClient())
      {

      
string RandomNumber = client.DownloadString("http://www.random.org/integers/?num=1&min=" + min + "&max=" + max + "&col=1&base=10&format=plain&rnd=new");
      return 
int.Parse(RandomNumber);

      }
      } 

This would generate a random number between 1 -100, and would be the most efficient way to go about achieving as close to "Random" as possible.

No offence but this is probably the worst method you can think of, using an external source that relies on an internet connection?

If the site goes down, if no internet connection is found, if the page is moved.. So many risky factors.


* - TheBarret - Sep 1, 2014

Tweet is Chrome trolling me or is the background color of your singature different from the hf bg color o.O

OT: I rather fuck a random hooker with the possibility to get scabbies then using your code.

- Barret


* - $lick - Sep 1, 2014

(Sep 1, 2014 06:45 PM)TheBarret Wrote:  Tweet is Chrome trolling me or is the background color of your singature different from the hf bg color o.O

OT: I rather fuck a random hooker with the possibility to get scabbies then using your code.

- Barret

Yeah he seems to be using a lighter version.


* - Rolex™ - Sep 2, 2014

(Sep 1, 2014 06:32 PM)Tweety. Wrote:  No offence but this is probably the worst method you can think of, using an external source that relies on an internet connection?

If the site goes down, if no internet connection is found, if the page is moved.. So many risky factors.

You're saying it's a bad idea though based off those factors. I'm saying it's the best idea provided that you have internet. Lets be honest I don't think Random.org is going down anytime soon.

I understand what you're saying, that you're relying on that source. It is the best METHOD though for randomness. Unless of course you wanted to duplicate getting randoms through atmospheric noise via VB.NET.


* - sh@rp - Sep 2, 2014

lol : caught red handed....
His intention was bad and it would be wise to close this thread !

I say this ......


* - ubbelol - Sep 4, 2014

(Sep 2, 2014 06:11 AM)Rolex™ Wrote:  You're saying it's a bad idea though based off those factors. I'm saying it's the best idea provided that you have internet. Lets be honest I don't think Random.org is going down anytime soon.

I understand what you're saying, that you're relying on that source. It is the best METHOD though for randomness. Unless of course you wanted to duplicate getting randoms through atmospheric noise via VB.NET.

The main issue is you're butchering the performance of a random function. Imagine if you need to quickly generate 1000 random numbers, your method will take quite a bit of time while the built-in random is near instant.


* - Bcoder - Sep 4, 2014

i dont understant what you do, but whatever good job :)


* - LordCoder - Sep 4, 2014

(Sep 2, 2014 06:11 AM)Rolex™ Wrote:  You're saying it's a bad idea though based off those factors. I'm saying it's the best idea provided that you have internet. Lets be honest I don't think Random.org is going down anytime soon.

I understand what you're saying, that you're relying on that source. It is the best METHOD though for randomness. Unless of course you wanted to duplicate getting randoms through atmospheric noise via VB.NET.

I still didn't see duplicate randoms by Random class USED properly. Of course it's quite similar because of the seed. Do your jobs and you'll get a ~95% random number. I did one in 5 mins, it's not difficult and no need to rely on a website.