Announcement

Collapse
No announcement yet.

An algo for making messy random strings.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    He he,

    Here is yet another variation that may slow down the whining. Add another acronym, it may sound profound.
    Code:
    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    
    FUNCTION randstr(ByVal ccnt as DWORD) as STRING
    
        #REGISTER NONE
    
        LOCAL var as DWORD
        LOCAL cnt as DWORD
    
        ! db &H0F,&H31
        ! db &H0F,&HC8
        ! mov var, eax
    
        randomize var
    
        src$ = ""
    
        cnt = 0
        ! mov esi, ccnt
    
      lbl:
        src$ = src$ + chr$(rnd(0,255))
        ! add cnt, 1
        ! cmp cnt, esi
        ! jne lbl
    
        FUNCTION = src$
    
    End FUNCTION
    
    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    > I looked at your post #16 and it did not do a lot for me.

    I can promise you the algo design, simple as it is was not designed to "do a lot" for anyone, it does what it is supposed to do, nothing else.
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #22
      Originally posted by Yours truly
      I say machine code because at the time I did not have an assembler and typed in hex code.
      ! db &H0F,&H31 ==> rdtsc
      ! db &H0F,&HC8 ==> bswap eax

      Not sneaky enough, Steve.

      You mentioned 'whining' and 'acronym' again. If you are trying to wind me up you will have to do better than that.

      ... it does what it is supposed to do, nothing else.
      So does RtlGenRandom( szClassName, 64 ).

      Comment


      • #23
        Repost of post #11 re post #9.

        Steve, question: What is 'mov rax, 100 ; out of range number' for?

        Comment


        • #24
          BTW, folks, Steve's post #9 reads the Time Stamp eleven times and in that case bswap comes into its own.

          Comment


          • #25
            David,

            Its an empty argument for the following CPUID instruction.
            If a value entered for CPUID.EAX is less than or equal to the maximum input value and the leaf is not supported on
            that processor then 0 is returned in all the registers.
            Now for all the waffle I have had to listen to, here is your penance, the video on building my latest Xeon box. https://www.youtube.com/watch?v=DV29EOEi6Mc
            hutch at movsd dot com
            The MASM Forum

            www.masm32.com

            Comment


            • #26
              Stuart,

              Sorry to be a bit slow, I had to find your post again. You are shifting from a basic dynamic string to a zero terminated string which is different to how its used. This test piece shows that basic string remains the length specified in the function call. Now if you come back to what the algo is used for in an application, a different string every time the app is run for both class names and private message strings, even if the string is interpreted as zero length, it does the job and will be different next time it is run.
              Code:
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
                  #include "\basic\include\win32api.inc"
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
              FUNCTION PBmain as LONG
              
                  LOCAL lcnt as DWORD
              
                  lcnt = 0
              
                lbl:
                  StdOut format$(len(randstr(128)))
                  ! add lcnt, 1
                  ! cmp lcnt, 1000
                  ! jbe lbl
              
                  waitkey$
              
              End FUNCTION
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              
              FUNCTION randstr(ByVal ccnt as DWORD) as STRING
              
                  #REGISTER NONE
              
                  LOCAL var as DWORD
                  LOCAL cnt as DWORD
              
                  ! db &H0F,&H31
                  ! db &H0F,&HC8
                  ! mov var, eax
              
                  randomize var
              
                  src$ = ""
              
                  cnt = 0
                  ! mov esi, ccnt
              
                lbl:
                  src$ = src$ + chr$(rnd(0,255))
                  ! add cnt, 1
                  ! cmp cnt, esi
                  ! jne lbl
              
                  FUNCTION = src$
              
              End FUNCTION
              
              ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
              hutch at movsd dot com
              The MASM Forum

              www.masm32.com

              Comment


              • #27
                Originally posted by Steve
                Its an empty argument for the following CPUID instruction.
                Gotcha!

                here is your penance
                Strewth!

                A 12/24 with 30MB cache. Wow, that is some kit.

                Comment


                • #28
                  Its a nice enough box to use, I have de-trashed most of the junk in Win10 64 and have most of the software loaded, it ingested another 4 tb WD red HDD and there is not much more to add to it. I may do a mod in the future of adding an NVMe drive in one of the PCI slots but I am tired of throwing money at it so there is no hurry. The board was the expensive bit, I got the Xeon from a vendor in China for about 1/10th the original cost.
                  hutch at movsd dot com
                  The MASM Forum

                  www.masm32.com

                  Comment


                  • #29
                    Hi Stuart,

                    This one should keep everyone happy, it excludes the ascii 0 and filters out numbers, upper and lower case and the output looks truly disgusting, exactly how I wanted this string data to look like.
                    Code:
                    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    
                        #include "\basic\include\win32api.inc"
                    
                    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    
                    FUNCTION PBmain as LONG
                    
                        LOCAL lcnt as DWORD
                    
                        lcnt = 1000
                    
                      lbl:
                        StdOut randstr
                        ! sub lcnt, 1
                        ! jnz lbl
                    
                        waitkey$
                    
                    End FUNCTION
                    
                    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    
                    FUNCTION randstr() as STRING
                    
                        #REGISTER NONE
                    
                        LOCAL var  as DWORD
                        LOCAL ccnt as DWORD
                        LOCAL rnm  as DWORD
                    
                        ! db &H0F,&H31
                        ! db &H0F,&HC8
                        ! mov var, eax
                    
                        randomize var                       ' seed the PB rnd function
                    
                        src$ = ""                           ' allocate an empty basic string
                    
                        ccnt = rnd(11,71)                   ' make output variable length
                        ! mov esi, ccnt
                    
                      lbl:
                        rnm = rnd(1,255)
                    
                        If rnm > 47 and rnm < 58 Then       ' no numbers
                          ! jmp lbl
                        End If
                    
                        If rnm > 64 and rnm < 91 Then       ' no upper case
                          ! jmp lbl
                        End If
                    
                        If rnm > 96 and rnm < 123 Then      ' no lower case
                          ! jmp lbl
                        End If
                    
                        src$ = src$ + chr$(rnm)
                    
                        ! sub esi, 1
                        ! jnz lbl
                    
                        FUNCTION = src$
                    
                    End FUNCTION
                    
                    ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
                    hutch at movsd dot com
                    The MASM Forum

                    www.masm32.com

                    Comment


                    • #30
                      Haha, this is really sort of Fake-ASM-Coding Hutch.
                      If you write "GOTO" there will be no difference because it will also compile to "JMP".
                      And the rest is just basic.
                      Especially the line "SRC$=SRC$+CHR$()" will be limiting the speed of the subprogramm.
                      This is where you need to make changes to speed things up.
                      --Theo Gottwald
                      ------------------------------------------------
                      76706 Dettenheim * Germany * [email protected]
                      ------------------------------------------------
                      Joses Forum * Theo's Link Site * IT-Berater.org

                      Comment


                      • #31


                        Theo, you could code a genuinely fast one but why bother, the string are just not long enough. Think of a 256 character table and a fast random but would you see the difference on a 1k string ?
                        hutch at movsd dot com
                        The MASM Forum

                        www.masm32.com

                        Comment

                        Working...
                        X