This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ry00000's profile picture

RandString - a random string generator API

Started by ry00000, 08 July 2016 - 01:28 PM
ry00000 #1
Posted 08 July 2016 - 03:28 PM
Here I am. Presenting my 1st actually useful program to the CC Community:
RandString!
An API for random string generation
(i know the title isn't very creative)
Features:
1) Fully customizeable! Uses ASCII so if you have an ASCII lookup table handy you can find the variables and change them to generate random characters!
2) ASCII powered! This program uses string.char() so that you can modify the generated string however you want!


So what are you waiting for?

pastebin get 2F0XGYCQ randstring to download this program!

Huuuuuge thanks to MudkipTheEpic for providing the generation routine!

Spoilerexample:

os.loadAPI("randstring")
print(randstring.makeString(<length>))
Edited on 09 July 2016 - 10:51 AM
ReBraLaCC #2
Posted 08 July 2016 - 04:05 PM
Question, what will this be usefull for? because if you're using it for password encryption you need to save the password itself aswell, maybe usefull for a keycard but other idk :)/> nice code
Cloud Ninja #3
Posted 08 July 2016 - 04:12 PM
Question, what will this be usefull for? because if you're using it for password encryption you need to save the password itself aswell, maybe usefull for a keycard but other idk :)/> nice code
You could do Key = randstring() file = fs.open("/file","w") file.write(key.." user") file.close() and now you have a key for that user, and if they enter it, itll work. Tada!
Lemmmy #4
Posted 08 July 2016 - 04:22 PM
stringtable[math.random(#stringtable)] is not secure random. Do not use it for encryption, passwords or the likes. Here is a program which can generate cryptographically secure random numbers - it is an API therefore you could interface it with RandString by using stringtable[csrng.random(1, #stringtable)] instead, or write your own implementation of a cryptographically secure random number generator algorithm.

To be secure, the generator cannot be predictable. With linear random number generators (the fast ones like math.random in lua) you can see the previous value and determine what the next one will be. With this algorithm, and with all cryptographically secure generators, even if you've seen all the numbers emitted so far, you cannot predict the next number. You have to know the seed, which is usually a well kept secret from hackers.
Edited on 08 July 2016 - 02:24 PM
ry00000 #5
Posted 09 July 2016 - 12:51 PM
This has absolutely NO intention to be cryptographically secure.
Edited on 09 July 2016 - 02:48 PM
Anavrins #6
Posted 09 July 2016 - 04:03 PM
Before you edited it, your post said that it could be used for encryption key, etc…
Not anymore I guess.