Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Random numbers (emphasis on seeding the number)

Random numbers (emphasis on seeding the number)

Scheduled Pinned Locked Moved The Lounge
cryptographylounge
72 Posts 25 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Slacker007

    A thought came to me today about random seed generation. I googlied a bit but found nothing (using image data)...still could be there. You have a series of images. you count the pixels and use that as your random seed. Delete the image. The images are constantly being replenished by new images of all shapes and sizes and formats from the internet or scanned in or whatever. I would "think", that if the images were gathered...at random...with no care at all, the seed value would be random and not predictable. I am not a crypto guru so you can laugh all you want. :)

    Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

    S Offline
    S Offline
    Spectre_001
    wrote on last edited by
    #47

    How about... public static Int32 random(Int32 lowerBound, Int32 upperBound) { Int32 range = (upperBound++) - lowerBound; byte[] seed = Guid.NewGuid().ToByteArray(); RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(seed); byte[] sequence = new byte[1]; rng.GetBytes(sequence); return (Int32)(sequence[0] % range) + lowerBound; }

    Kevin Rucker, Application Programmer QSS Group, Inc. United States Coast Guard OSC Kevin.D.Rucker@uscg.mil "Programming is an art form that fights back." -- Chad Hower

    S 1 Reply Last reply
    0
    • S Spectre_001

      How about... public static Int32 random(Int32 lowerBound, Int32 upperBound) { Int32 range = (upperBound++) - lowerBound; byte[] seed = Guid.NewGuid().ToByteArray(); RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(seed); byte[] sequence = new byte[1]; rng.GetBytes(sequence); return (Int32)(sequence[0] % range) + lowerBound; }

      Kevin Rucker, Application Programmer QSS Group, Inc. United States Coast Guard OSC Kevin.D.Rucker@uscg.mil "Programming is an art form that fights back." -- Chad Hower

      S Offline
      S Offline
      Slacker007
      wrote on last edited by
      #48

      There is no perfect Random generator. All I was doing was getting community feedback on an idea I was toying with on "seeding" RNG's. The whole idea being that you cannot generate the seed. The seed has to be random. Well, how do you get random? My idea was to use some sort of random "image/picture" grab from the net and use the pixel count of that image as your seed. I'm sure color count or something similar could be used as well...as long as you are not in monochrome format or the like. Thanks for the suggestion.

      Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
      "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

      S 1 Reply Last reply
      0
      • S Slacker007

        jschell wrote:

        Do you see any circles there?

        do you because I don't. The images are random by nature. I don't create the randomness in that, the internet does. I use that natural randomness of the images to seed my random number. The only thing I am creating is the final random number.

        Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

        S Offline
        S Offline
        Stefan_Lang
        wrote on last edited by
        #49

        You seem to assume that the randomness of the content of pictures from the internet in general makes your specific pick somehow random. It doesn't! Unless you use some kind of random element, you will pick a very specific picture from a very specific URL, and every other person doing the same will get exactly the same image if following that algorithm. The only random element here is the point in time that you choose to select and download that picture (and even that will only make a difference if you're talking about some image feed channel like you mentioned). So, in the end, you've based your random number on the current time, just like everyone else! :)

        S 1 Reply Last reply
        0
        • S Stefan_Lang

          You seem to assume that the randomness of the content of pictures from the internet in general makes your specific pick somehow random. It doesn't! Unless you use some kind of random element, you will pick a very specific picture from a very specific URL, and every other person doing the same will get exactly the same image if following that algorithm. The only random element here is the point in time that you choose to select and download that picture (and even that will only make a difference if you're talking about some image feed channel like you mentioned). So, in the end, you've based your random number on the current time, just like everyone else! :)

          S Offline
          S Offline
          Slacker007
          wrote on last edited by
          #50

          Actually, no. If you have ever been on 4Chan then you would understand what I am talking about. You also need to know that there is no way for you to grab the image at the same time I am because you have no idea when I'm grabbing it. Images on 4Chan come and go (get moved or deleted) every second. If you don't know when I am going to grab that image, then you have no idea what my seed value was or is.

          Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
          "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

          S 1 Reply Last reply
          0
          • S Slacker007

            A thought came to me today about random seed generation. I googlied a bit but found nothing (using image data)...still could be there. You have a series of images. you count the pixels and use that as your random seed. Delete the image. The images are constantly being replenished by new images of all shapes and sizes and formats from the internet or scanned in or whatever. I would "think", that if the images were gathered...at random...with no care at all, the seed value would be random and not predictable. I am not a crypto guru so you can laugh all you want. :)

            Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

            S Offline
            S Offline
            Stefan_Lang
            wrote on last edited by
            #51

            If you want true randomness, use hardware-based random number generators[^]. :) The RNG in this article is based on thermal noise on your personal hardware, so anyone trying to duplicate your sequence of random numbers will need to have physical access to your hardware. P.S.: you could probably build something like this yourself if you can read the temperature from certain hardware components, such as your graphics core - I know there is software that can display such values, so it must be possible to read them.

            S 1 Reply Last reply
            0
            • S Stefan_Lang

              If you want true randomness, use hardware-based random number generators[^]. :) The RNG in this article is based on thermal noise on your personal hardware, so anyone trying to duplicate your sequence of random numbers will need to have physical access to your hardware. P.S.: you could probably build something like this yourself if you can read the temperature from certain hardware components, such as your graphics core - I know there is software that can display such values, so it must be possible to read them.

              S Offline
              S Offline
              Slacker007
              wrote on last edited by
              #52

              This is what I am talking about. Thanks for the link. My belief as well as others is that, you have to get your seed from a random occurring event. You can't create the seed, it has to be created for you. This really was my argument, I just don't put down my thoughts very well sometimes. Again, thanks for the link. :thumbsup:

              Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
              "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

              1 Reply Last reply
              0
              • S Slacker007

                A thought came to me today about random seed generation. I googlied a bit but found nothing (using image data)...still could be there. You have a series of images. you count the pixels and use that as your random seed. Delete the image. The images are constantly being replenished by new images of all shapes and sizes and formats from the internet or scanned in or whatever. I would "think", that if the images were gathered...at random...with no care at all, the seed value would be random and not predictable. I am not a crypto guru so you can laugh all you want. :)

                Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                F Offline
                F Offline
                Fabio Franco
                wrote on last edited by
                #53

                You could put a microphone on your local sewer dump, record the random crap splash sounds and from there seed your random crap number generator. :laugh: That basic need can be unpleasantly random.

                "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                S 1 Reply Last reply
                0
                • D Dalek Dave

                  Perform a series of rolls, apply a scalar algorythm et voilà.

                  ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC Link[^] Trolls[^]

                  D Offline
                  D Offline
                  DaveAuld
                  wrote on last edited by
                  #54

                  Dalek Dave wrote:

                  a series of rolls

                  Bacon rolls? nom, nom, nom........

                  Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                  Folding Stats: Team CodeProject

                  1 Reply Last reply
                  0
                  • F Fabio Franco

                    You could put a microphone on your local sewer dump, record the random crap splash sounds and from there seed your random crap number generator. :laugh: That basic need can be unpleasantly random.

                    "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                    S Offline
                    S Offline
                    Slacker007
                    wrote on last edited by
                    #55

                    Although your post was geared to be funny, and it was, it proves my point. Using digital output from anything around us in the physical world and the digital world would work.

                    Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                    F 1 Reply Last reply
                    0
                    • C Chris Meech

                      The capacity is limited to only three numbers (2,3 and 6). How's that random? ;P

                      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                      J Offline
                      J Offline
                      jsc42
                      wrote on last edited by
                      #56

                      Actually, the random number should be 4, according to RFC 1149.5. For confirmation, see http://www.xkcd.com/221/[^]

                      1 Reply Last reply
                      0
                      • S Slacker007

                        Although your post was geared to be funny, and it was, it proves my point. Using digital output from anything around us in the physical world and the digital world would work.

                        Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                        F Offline
                        F Offline
                        Fabio Franco
                        wrote on last edited by
                        #57

                        I guess you're right. Random it will be. And I tend to believe that nothing is more random than nature (if it is at all), in your case, pictures taken and uploaded by people (nature). I'd just use another method, instead of dimensions, I'd get a few pixels from the pictures and with some sort of algorithm, create the seed. If security is not a concearn, than both our methods would work. The difference is, your are not so nasty.

                        "To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson

                        1 Reply Last reply
                        0
                        • S Slacker007

                          A thought came to me today about random seed generation. I googlied a bit but found nothing (using image data)...still could be there. You have a series of images. you count the pixels and use that as your random seed. Delete the image. The images are constantly being replenished by new images of all shapes and sizes and formats from the internet or scanned in or whatever. I would "think", that if the images were gathered...at random...with no care at all, the seed value would be random and not predictable. I am not a crypto guru so you can laugh all you want. :)

                          Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                          "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                          B Offline
                          B Offline
                          BrainiacV
                          wrote on last edited by
                          #58

                          I think the solution is here[^]

                          Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                          1 Reply Last reply
                          0
                          • S Slacker007

                            There is no perfect Random generator. All I was doing was getting community feedback on an idea I was toying with on "seeding" RNG's. The whole idea being that you cannot generate the seed. The seed has to be random. Well, how do you get random? My idea was to use some sort of random "image/picture" grab from the net and use the pixel count of that image as your seed. I'm sure color count or something similar could be used as well...as long as you are not in monochrome format or the like. Thanks for the suggestion.

                            Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                            S Offline
                            S Offline
                            Spectre_001
                            wrote on last edited by
                            #59

                            Absolutely true, there is no perfect random number generator. I was just showing an example of using the Windows Guid generator (pretty darn random) to seed the RNG. Really it's kind of a moot point, in that, according to MSDN the RNG seed value is ignored in the present implementation. It uses some undisclosed seeding method internal to the constructor.

                            Kevin Rucker, Application Programmer QSS Group, Inc. United States Coast Guard OSC Kevin.D.Rucker@uscg.mil "Programming is an art form that fights back." -- Chad Hower

                            1 Reply Last reply
                            0
                            • S Slacker007

                              Actually, no. If you have ever been on 4Chan then you would understand what I am talking about. You also need to know that there is no way for you to grab the image at the same time I am because you have no idea when I'm grabbing it. Images on 4Chan come and go (get moved or deleted) every second. If you don't know when I am going to grab that image, then you have no idea what my seed value was or is.

                              Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                              "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                              S Offline
                              S Offline
                              Stefan_Lang
                              wrote on last edited by
                              #60

                              You didn't get my meaning - my point was not whether I know or not when you're grabbing it, but that the only random component in your 'algorithm' is exactly that: when you're grabbing it. And that's a time stamp. So you can just as well use that time stamp as your seed.

                              S 1 Reply Last reply
                              0
                              • S Stefan_Lang

                                You didn't get my meaning - my point was not whether I know or not when you're grabbing it, but that the only random component in your 'algorithm' is exactly that: when you're grabbing it. And that's a time stamp. So you can just as well use that time stamp as your seed.

                                S Offline
                                S Offline
                                Slacker007
                                wrote on last edited by
                                #61

                                I'm not using time at all. I am using the image properties. I don't care about the time. It is not even part of the equation. I would never use time to seed a rng.

                                Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                                S 1 Reply Last reply
                                0
                                • C Chris Meech

                                  Isn't

                                  rand(42);

                                  random enough for you. :cool:

                                  Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                                  M Offline
                                  M Offline
                                  mght
                                  wrote on last edited by
                                  #62

                                  Chris Meech wrote:

                                  Isn't

                                  rand(42);

                                  random enough for you. :cool:

                                  No.

                                  rand(rand(42));

                                  Now with twice the randomness!

                                  // mbghtri ToDo: // Put Signature Here

                                  1 Reply Last reply
                                  0
                                  • S Slacker007

                                    A thought came to me today about random seed generation. I googlied a bit but found nothing (using image data)...still could be there. You have a series of images. you count the pixels and use that as your random seed. Delete the image. The images are constantly being replenished by new images of all shapes and sizes and formats from the internet or scanned in or whatever. I would "think", that if the images were gathered...at random...with no care at all, the seed value would be random and not predictable. I am not a crypto guru so you can laugh all you want. :)

                                    Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                                    M Offline
                                    M Offline
                                    MagicBishop
                                    wrote on last edited by
                                    #63

                                    I use ranGens allot for simulated hardware. My seed solution that never fails. Random number seeded with QueryPerformanceCounter and then reseeding random number and using the random number from the last seed as a Mod on a new call to QPCntr.

                                    1 Reply Last reply
                                    0
                                    • S Slacker007

                                      jschell wrote:

                                      Do you see any circles there?

                                      do you because I don't. The images are random by nature. I don't create the randomness in that, the internet does. I use that natural randomness of the images to seed my random number. The only thing I am creating is the final random number.

                                      Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                      "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                                      J Offline
                                      J Offline
                                      jschell
                                      wrote on last edited by
                                      #64

                                      Slacker007 wrote:

                                      do you because I don't.

                                      It was explicit in the statement.

                                      Slacker007 wrote:

                                      The images are random by nature.

                                      That is inprecise. There are two parts to it. 1. The content of picture A. 2. The selection of picture A in the first place. If you use a 'random' process to arrive at 2 then the methodology for 'random' in that case is open to question.

                                      1 Reply Last reply
                                      0
                                      • S Slacker007

                                        I'm not using time at all. I am using the image properties. I don't care about the time. It is not even part of the equation. I would never use time to seed a rng.

                                        Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                                        S Offline
                                        S Offline
                                        Stefan_Lang
                                        wrote on last edited by
                                        #65

                                        The image properties depend on the image. That part is deterministic and not random at all. The image depends on the exact time. Once you know the time, determining the image is not random at all either. It all comes down to when you grab the image, because that determines the image. when is time. It's about time you realize that.

                                        S 1 Reply Last reply
                                        0
                                        • S Stefan_Lang

                                          The image properties depend on the image. That part is deterministic and not random at all. The image depends on the exact time. Once you know the time, determining the image is not random at all either. It all comes down to when you grab the image, because that determines the image. when is time. It's about time you realize that.

                                          S Offline
                                          S Offline
                                          Slacker007
                                          wrote on last edited by
                                          #66

                                          I don't think you understand anything about image dumps (sites that people, all over the world, upload images to). You seem to focus on time. Time is not important here. There is no other way I can get this idea through to you. You seem to be fixated on time. Time is irrelevant here.

                                          Stefan_Lang wrote:

                                          The image properties depend on the image. That part is deterministic and not random at all.

                                          wrong. every image has it's own properties. every image is different then the next. the image i grab is random; their for the properties I work from are random.

                                          Just along for the ride. "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                          "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011)

                                          S 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups