Log In  

0

Cart [#46269#] | Copy | Code | 2017-11-14 | Link
0

A little password generator I lazily threw together for some tables practice.
Feel free to use it for actual passwords!
(It's literally just a string of random numbers and letters)

Special thanks to kittenm4ster for helping me fix something in the code, making the generator consistent! :)

P#46261 2017-11-13 21:38

::

There's no point in calling srand() with a rnd() value; that will not give you any additional entropy.

Also, the PRNG is automatically seeded every time you start running a cart, so there's not really a reason to even call srand() unless you are trying to reproduce the same sequence in the PRNG for debugging purposes or whatever.

You probably already know this, but the other thing to note is that the PRNG in PICO-8 is almost certainly (unless zep really went above and beyond!) not cryptographically secure and not intended for use in security applications. Security and gamedev have very different requirements for randomness; in gamedev you can get away with using a pretty low-entropy PRNG and still get great results :)

As for why you don't get the same number of characters every time, just from a cursory reading of the code, it looks to me like you are generating a random number from 0-34 (inclusive) and then if that number is > 9 then you are using it as an index into your table of letters, so you are only ever starting at the 10th letter in your table, and sometimes, going past the end of the table (when the number is > 26) which results in no letter being returned from the table lookup.

P#46264 2017-11-14 00:00

::

I did the srand() because I was just looking at the wiki and thought "Hey why not"

Also thank you so much!!! I can't believe I didn't notice that!! I'm going to use your suggestion to fix it :)

P#46267 2017-11-14 00:26

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2017-11-20 01:59 | 0.199s | 1572k | Q:19