Skip to content
  • Hjem
  • Seneste
  • Etiketter
  • Populære
  • Verden
  • Bruger
  • Grupper
Temaer
  • Light
  • Brite
  • 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
Kollaps
FARVEL BIG TECH
  1. Forside
  2. Ikke-kategoriseret
  3. For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

Planlagt Fastgjort Låst Flyttet Ikke-kategoriseret
25 Indlæg 21 Posters 0 Visninger
  • Ældste til nyeste
  • Nyeste til ældste
  • Most Votes
Svar
  • Svar som emne
Login for at svare
Denne tråd er blevet slettet. Kun brugere med emne behandlings privilegier kan se den.
  • ahltorp@mastodon.nuA ahltorp@mastodon.nu

    @robinhouston This is a direct consequence of what the note at the top of Python's "random" module warns about:

    "Warning: The pseudo-random generators of this module should not be used for security purposes. For security or cryptographic uses, see the secrets module."

    robinhouston@mathstodon.xyzR This user is from outside of this forum
    robinhouston@mathstodon.xyzR This user is from outside of this forum
    robinhouston@mathstodon.xyz
    wrote sidst redigeret af
    #10

    @ahltorp Well, I certainly wouldn't expect the output to be unpredictable given a known seed! But it's cool that it's possible to derive a seed that forces a specific sequence of outputs like that.

    ahltorp@mastodon.nuA 1 Reply Last reply
    0
    • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

      @ahltorp Well, I certainly wouldn't expect the output to be unpredictable given a known seed! But it's cool that it's possible to derive a seed that forces a specific sequence of outputs like that.

      ahltorp@mastodon.nuA This user is from outside of this forum
      ahltorp@mastodon.nuA This user is from outside of this forum
      ahltorp@mastodon.nu
      wrote sidst redigeret af
      #11

      @robinhouston Yes, any pseudo-number function must produce the same results each time you run it, that is what "function" means in mathematics. But that is not what is normally meant by "predictable".

      What the warning is about is that the results of the "random" module are predictable in a very different way. The function is analysable, which means that you can predict it backwards and forwards, skip over steps, etc.

      Cryptographically strong functions are not analysable.

      1 Reply Last reply
      0
      • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

        He's just confessed how he did it!

        https://github.com/frazerpearce/TimeLord

        thomastc@mastodon.gamedev.placeT This user is from outside of this forum
        thomastc@mastodon.gamedev.placeT This user is from outside of this forum
        thomastc@mastodon.gamedev.place
        wrote sidst redigeret af
        #12

        @robinhouston Super cool! I guess this is only possible because the Mersenne Twister has such a huge state space (2 kB), making it likely that a valid seed exists. I think e.g. the PCG64 generator has only 128 bits of state, so any requested output of that length or longer would not likely be reproducible.

        colinvparker@mathstodon.xyzC 1 Reply Last reply
        0
        • ahltorp@mastodon.nuA ahltorp@mastodon.nu

          @robinhouston This is a direct consequence of what the note at the top of Python's "random" module warns about:

          "Warning: The pseudo-random generators of this module should not be used for security purposes. For security or cryptographic uses, see the secrets module."

          mattiebee@queer.gardenM This user is from outside of this forum
          mattiebee@queer.gardenM This user is from outside of this forum
          mattiebee@queer.garden
          wrote sidst redigeret af
          #13

          @ahltorp @robinhouston yes, that’s indeed how it works, but this is still tremendously cool and delightful

          ahltorp@mastodon.nuA 1 Reply Last reply
          0
          • mattiebee@queer.gardenM mattiebee@queer.garden

            @ahltorp @robinhouston yes, that’s indeed how it works, but this is still tremendously cool and delightful

            ahltorp@mastodon.nuA This user is from outside of this forum
            ahltorp@mastodon.nuA This user is from outside of this forum
            ahltorp@mastodon.nu
            wrote sidst redigeret af
            #14

            @mattiebee @robinhouston The reason the demonstration is cool and delightful is because it plays on our expectations that it should not be possible, or at least very hard.

            And in this case it turns out not to be hard, since cryptographically it's just a normal preimage attack on a system designed with no preimage resistance.

            Be amazed, and then learn why your expectations were not correct.

            1 Reply Last reply
            0
            • thomastc@mastodon.gamedev.placeT thomastc@mastodon.gamedev.place

              @robinhouston Super cool! I guess this is only possible because the Mersenne Twister has such a huge state space (2 kB), making it likely that a valid seed exists. I think e.g. the PCG64 generator has only 128 bits of state, so any requested output of that length or longer would not likely be reproducible.

              colinvparker@mathstodon.xyzC This user is from outside of this forum
              colinvparker@mathstodon.xyzC This user is from outside of this forum
              colinvparker@mathstodon.xyz
              wrote sidst redigeret af
              #15

              @thomastc @robinhouston It’s only likely that a valid seed exists when using a large internal state, but it’s a little surprising that the process is reversible, because brute force search across seeds would be infeasible.

              gsuberland@chaos.socialG 1 Reply Last reply
              0
              • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                I find it rather amazing that this is possible!

                This is the program he sent with the seed:

                with open("seed.txt", encoding="ascii") as handle:
                seed = int(handle.read().strip(), 0)
                r = random.Random(seed)
                pending = ""
                while True:
                character = chr(r.randrange(128))
                if pending + character == "\x1e\x1f":
                break
                print(pending, end="")
                pending = character
                print()

                evoscale@c.imE This user is from outside of this forum
                evoscale@c.imE This user is from outside of this forum
                evoscale@c.im
                wrote sidst redigeret af
                #16

                @robinhouston If I stare at it long enough, will my birthdays reverse?.. cuz I'm feelin' pretty freakin' old...

                1 Reply Last reply
                0
                • colinvparker@mathstodon.xyzC colinvparker@mathstodon.xyz

                  @thomastc @robinhouston It’s only likely that a valid seed exists when using a large internal state, but it’s a little surprising that the process is reversible, because brute force search across seeds would be infeasible.

                  gsuberland@chaos.socialG This user is from outside of this forum
                  gsuberland@chaos.socialG This user is from outside of this forum
                  gsuberland@chaos.social
                  wrote sidst redigeret af
                  #17

                  @Colinvparker @thomastc @robinhouston the trick is that, if only a few bits of the output are constrained, then you only have to solve for a state sequence that produces the right constrained bits, and the other bits are free to change. that reduces the complexity of the maths a lot.

                  1 Reply Last reply
                  0
                  • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                    For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                    I find it rather amazing that this is possible!

                    This is the program he sent with the seed:

                    with open("seed.txt", encoding="ascii") as handle:
                    seed = int(handle.read().strip(), 0)
                    r = random.Random(seed)
                    pending = ""
                    while True:
                    character = chr(r.randrange(128))
                    if pending + character == "\x1e\x1f":
                    break
                    print(pending, end="")
                    pending = character
                    print()

                    agitatra@berlin.socialA This user is from outside of this forum
                    agitatra@berlin.socialA This user is from outside of this forum
                    agitatra@berlin.social
                    wrote sidst redigeret af
                    #18

                    @robinhouston This sounds like a bigger problem.

                    1 Reply Last reply
                    0
                    • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                      He's just confessed how he did it!

                      https://github.com/frazerpearce/TimeLord

                      N This user is from outside of this forum
                      N This user is from outside of this forum
                      napili@hachyderm.io
                      wrote sidst redigeret af
                      #19

                      @robinhouston someone needs to make a quine out of this!

                      1 Reply Last reply
                      0
                      • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                        He's just confessed how he did it!

                        https://github.com/frazerpearce/TimeLord

                        mags@post.lurk.orgM This user is from outside of this forum
                        mags@post.lurk.orgM This user is from outside of this forum
                        mags@post.lurk.org
                        wrote sidst redigeret af
                        #20

                        @robinhouston oh hey, he supervised one of my projects last year!

                        1 Reply Last reply
                        0
                        • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                          For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                          I find it rather amazing that this is possible!

                          This is the program he sent with the seed:

                          with open("seed.txt", encoding="ascii") as handle:
                          seed = int(handle.read().strip(), 0)
                          r = random.Random(seed)
                          pending = ""
                          while True:
                          character = chr(r.randrange(128))
                          if pending + character == "\x1e\x1f":
                          break
                          print(pending, end="")
                          pending = character
                          print()

                          realcainmosni@mastodon.me.ukR This user is from outside of this forum
                          realcainmosni@mastodon.me.ukR This user is from outside of this forum
                          realcainmosni@mastodon.me.uk
                          wrote sidst redigeret af
                          #21

                          @robinhouston Ably demonstrating that machine "randomisation", isn't.

                          1 Reply Last reply
                          0
                          • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                            For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                            I find it rather amazing that this is possible!

                            This is the program he sent with the seed:

                            with open("seed.txt", encoding="ascii") as handle:
                            seed = int(handle.read().strip(), 0)
                            r = random.Random(seed)
                            pending = ""
                            while True:
                            character = chr(r.randrange(128))
                            if pending + character == "\x1e\x1f":
                            break
                            print(pending, end="")
                            pending = character
                            print()

                            tartley@fosstodon.orgT This user is from outside of this forum
                            tartley@fosstodon.orgT This user is from outside of this forum
                            tartley@fosstodon.org
                            wrote sidst redigeret af
                            #22

                            @robinhouston can you all stop boosting this wonderful thing so that I can send a version of it to my friend for his birthday?

                            1 Reply Last reply
                            0
                            • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                              For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                              I find it rather amazing that this is possible!

                              This is the program he sent with the seed:

                              with open("seed.txt", encoding="ascii") as handle:
                              seed = int(handle.read().strip(), 0)
                              r = random.Random(seed)
                              pending = ""
                              while True:
                              character = chr(r.randrange(128))
                              if pending + character == "\x1e\x1f":
                              break
                              print(pending, end="")
                              pending = character
                              print()

                              nuintari@mastodon.bsd.cafeN This user is from outside of this forum
                              nuintari@mastodon.bsd.cafeN This user is from outside of this forum
                              nuintari@mastodon.bsd.cafe
                              wrote sidst redigeret af
                              #23

                              @robinhouston A million monkeys writing Python will eventually write Happy Birthday! I love it!

                              Happy Birthday!

                              1 Reply Last reply
                              0
                              • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                                For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.

                                I find it rather amazing that this is possible!

                                This is the program he sent with the seed:

                                with open("seed.txt", encoding="ascii") as handle:
                                seed = int(handle.read().strip(), 0)
                                r = random.Random(seed)
                                pending = ""
                                while True:
                                character = chr(r.randrange(128))
                                if pending + character == "\x1e\x1f":
                                break
                                print(pending, end="")
                                pending = character
                                print()

                                scruss@xoxo.zoneS This user is from outside of this forum
                                scruss@xoxo.zoneS This user is from outside of this forum
                                scruss@xoxo.zone
                                wrote sidst redigeret af
                                #24

                                @robinhouston a bit like Tristan Miller's very silly "The Great Commodore/Microsoft Easter
                                Egg War" from 2015, which claims there are secret messages encoded in Commodore BASIC's RND() function ...
                                https://www.tpug.ca/tpug-media/nl/91-Fall2015.pdf#page=7

                                1 Reply Last reply
                                0
                                • robinhouston@mathstodon.xyzR robinhouston@mathstodon.xyz

                                  He's just confessed how he did it!

                                  https://github.com/frazerpearce/TimeLord

                                  lee_holmes@infosec.exchangeL This user is from outside of this forum
                                  lee_holmes@infosec.exchangeL This user is from outside of this forum
                                  lee_holmes@infosec.exchange
                                  wrote sidst redigeret af
                                  #25

                                  @robinhouston Very cool! If he enjoyed that, he would probably enjoy this as well - I fell into a similar rabbit hole with Python hashing 🙂

                                  https://www.leeholmes.com/efficiently-generating-python-hash-collisions/

                                  1 Reply Last reply
                                  0
                                  • niels@social.data.coopN niels@social.data.coop shared this topic
                                  Svar
                                  • Svar som emne
                                  Login for at svare
                                  • Ældste til nyeste
                                  • Nyeste til ældste
                                  • Most Votes


                                  • Log ind

                                  • Login or register to search.
                                  Powered by NodeBB Contributors
                                  Graciously hosted by data.coop
                                  • First post
                                    Last post
                                  0
                                  • Hjem
                                  • Seneste
                                  • Etiketter
                                  • Populære
                                  • Verden
                                  • Bruger
                                  • Grupper