Post Reply 
(48) Password Generator
08-04-2014, 11:28 AM
Post: #3
RE: (48) Password Generator
(08-04-2014 03:35 AM)Joe Horn Wrote:  
(08-03-2014 01:07 PM)Dave Britten Wrote:  
Code:
\<< DUP SIZE \-> L C S
  \<< "" 1 L
    START C RAND S * 1 + DUP SUB +
    NEXT
  \>>
\>>

Please note that the first character in the input string will have a greater probability of getting picked than any other, and the final one will have less probability, and sometimes the output will be shorter than L, since SUB rounds to the nearest integer. I therefore suggest replacing 1 + with CEIL. This evens out the probabilities, fixes the length bug, and is a tad shorter and faster too.

Thanks Joe, can't believe I missed that. I blame the fact that I'm in the hospital for a couple days, and was on pain medication when I wrote that. Wink
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(48) Password Generator - Dave Britten - 08-03-2014, 01:07 PM
RE: (48) Password Generator - Joe Horn - 08-04-2014, 03:35 AM
RE: (48) Password Generator - Dave Britten - 08-04-2014 11:28 AM
RE: (48) Password Generator - pier4r - 03-22-2017, 04:38 PM



User(s) browsing this thread: 1 Guest(s)