Announcement
Collapse
No announcement yet.
An algo for making messy random strings.
Collapse
X
-
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 ?
Leave a comment:
-
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.
Leave a comment:
-
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 ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Leave a comment:
-
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.
Leave a comment:
-
Originally posted by SteveIts an empty argument for the following CPUID instruction.
here is your penance
A 12/24 with 30MB cache. Wow, that is some kit.
Leave a comment:
-
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 ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Leave a comment:
-
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.
Leave a comment:
-
BTW, folks, Steve's post #9 reads the Time Stamp eleven times and in that case bswap comes into its own.
Leave a comment:
-
Repost of post #11 re post #9.
Steve, question: What is 'mov rax, 100 ; out of range number' for?
Leave a comment:
-
Originally posted by Yours trulyI say machine code because at the time I did not have an assembler and typed in hex code.
! 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.
Leave a comment:
-
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 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.
Leave a comment:
-
Originally posted by SteveYou appear to have missed what the posted algo does
how many unintelligible acronyms have I heard out of you over the last few years ?
your whining seems to have missed the rest of the mnemonics
Now the only reason I can think of is that both you and Stuart are suffering lockdown boredom ...
I looked at your post #16 and it did not do a lot for me.
as long as you don't look at the macro.
Leave a comment:
-
WTF?
Using CHR$(0 to 255) to generate a Windows class name (NULL-TERMINATED) string?
The most you can lose is one trailing zero and remember, its being written to a basic dynamic string that can contain ascii zeros.
Leave a comment:
-
Stuart,
> WIth a register that is rotating through the 2^32 values in the DWORD about every 2 seconds and a single request for a seed for the RNG, what is the "sequential" aspect you are so concerned about?
You have misunderstood BSWAP. It does not rotate the register, it reverses the byte order.
00112233 becomes 33221100
Leave a comment:
-
OK, I finally looked at the algorithm link.
WTF?
Using RND(0 to 255) to generate a Windows class name (NULL-TERMINATED) string?
1 in 256 times, you generate a NULL string.
I'll leave it up to others to work out how many times you end up with a 1,2 or 3 character string
Added: Ok, I decided to do it myself;
'Code:#COMPILE EXE FUNCTION PBMAIN() AS LONG LOCAL x,y AS LONG LOCAL q AS QUAD LOCAL s AS STRING LOCAL sWinName AS STRINGZ*65 LOCAL hTxt AS DWORD DIM aLen(0 TO 64) AS LONG TIX q RANDOMIZE LO(DWORD,q) FOR x = 1 TO 10000 s="" FOR y = 1 TO 64 s+=CHR$(RND(0,255)) NEXT sWinName = s INCR aLen(LEN(sWinName)) NEXT s="Len Count" & $LF FOR x = 0 TO 3 s += STR$(x) & $TAB & STR$(aLen(x)) & $LF NEXT ? s END FUNCTION '
Leave a comment:
-
Here is a variation that should keep you happy as long as you don't look at the macro.
Code:' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ MACRO Dont_Call_This_Reseeding MACROTEMP nvar LOCAL nvar as DWORD ! rdtsc ! bswap eax ! mov nvar, eax randomize nvar END MACRO FUNCTION randstr(ByVal ccnt as DWORD) as STRING #REGISTER NONE LOCAL cnt as DWORD Dont_Call_This_Reseeding 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 ' ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Leave a comment:
-
Leave a comment:
-
> What bias? I cannot be bothered to search for it but you introduced the '! rdtsc, ! bswap eax' combo quite a while ago and reintroduced it again only recently. You then use it again in the opening post's link. That is what I meant with "flogging the death out of ...".
You appear to have missed what the posted algo does, it seeded the PB randomize so that the following loop could produce a sequence of random characters. It used the old PB rnd so it was easier to understand and was very simple code.
The seeding is small, fast and extremely difficult to duplicate yet there are many bigger, slower techniques that could be use, get the result from GetTickCount and BSWAP it but that involves an API call. There are many other methods but I doubt they are that small or as fast as the RDTSC BSWAP combination.
Now as far as "flogging to death", how many unintelligible acronyms have I heard out of you over the last few years ?
As far as the choice of mnemonics, your whining seems to have missed the rest of the mnemonics.
Code:MOV ADD CMP JNE
Now the only reason I can think of is that both you and Stuart are suffering lockdown boredom, can't you find a good movie to watch, roll on down to your local pub and do injustice to a few pints, go for a walk in the park or something productive ?
Leave a comment:
-
Originally posted by David Roberts View PostUsing bswap made sense to me, destroying the sequential aspect of rdtsc, and I could not understand the objections to it.
Unless you are re-seeding the RNG repeatedly in a very short time frame there is no "sequential aspect".. The BSWAP is superfluous in this use case
Leave a comment:
Leave a comment: