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

Password Generator

Started by Sammich Lord, 13 November 2012 - 06:37 PM
Sammich Lord #1
Posted 13 November 2012 - 07:37 PM
This script was created as a request from my friend.
The script will randomly print a string of chosen length or random if the argument says "ran", of random letters, numbers and basic symbols.

local args = {...}
local chars = {"a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "-", "_", "#", "%", "$", "*", "+"}
local pass = ""
if args[1] ~= "ran" then
  char = tonumber(args[1])
else
  char = math.random(8, 32)
end
for i = 1, char do
  local ranChar = math.random(1, #chars)
  pass = pass..chars[ranChar]
end
print(pass)
I realize this could of been done with "string.char()" however, I got lazy and I only wanted chars that ALMOST every keyboard has. You can edit out the "$" in the table if your keyboard does not support this.

Note: I do realize how simple this is however, I find it useful to use if you want to be safe. I also do not plan on updating this since it is so simple.
Mandrake Fernflower #2
Posted 14 November 2012 - 06:37 AM
could be used for some encryption thing. +1
Sammich Lord #3
Posted 14 November 2012 - 06:54 AM
could be used for some encryption thing. +1
It is not encryption. This is completely random. This was designed so you can random get a password when you wanted a new account. So you run the script, write the output down in a notebook, then when ever you need to login you just look at the notebook. This is meant to make password hard to bruteforce, due to the fact that it is completely random.
rick3333 #4
Posted 15 January 2013 - 02:47 PM
I keep getting a error at
for i = 1, char do
how do you fix this
Zudo #5
Posted 17 April 2013 - 08:21 AM
I keep getting a error at
for i = 1, char do
how do you fix this

local args = {...}
local chars = {"a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "!", "@", "-", "_", "#", "%", "$", "*", "+"}
local pass = ""
char = math.random(8, 32)
for i = 1, char do
  local ranChar = math.random(1, #chars)
  pass = pass..chars[ranChar]
end
print(pass)
Try this.
Cranium #6
Posted 17 April 2013 - 08:41 AM
Locked upon request.