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

Password Generator

Started by Conn332, 24 February 2013 - 11:27 AM
Conn332 #1
Posted 24 February 2013 - 12:27 PM
Hey everyone,
I've made a new program that generates a password for you depending on what you want.
The first thing it asks you for is the length of the password
The next thing it does is take you to a screen that prompts you for the modes of the password.
What this is asking you to do is enter the different types of characters you want in the password, so for example if I wanted a password that only contains upper case letter, lower case letters, and numbers then I would press the numbers u, l, n and then the words upper, lower, and number should show up.
And then finally press enter to finish and get your password.
The program stores the password in a file called pass for later use

You can get it from http://pastebin.com/nuLM7Zj9

Edit: Fixed the mds bug and added a length limit of 50
remiX #2
Posted 24 February 2013 - 12:43 PM
Pretty cool, definitely makes some random-pseudo passwords :)/>

But it does not work because you haven't defined mds.

You need to change the part where you select Upper/lower/special/number to this:
Spoiler
mds = ""
while true do
  event, key = os.pullEvent("key")
  if key == 22 then
    if u == false then
      u = true
      term.setCursorPos(1,7)
      print"Upper"
	  mds = mds .. 'u'
    else
      u = false
      term.setCursorPos(1,7)
      term.clearLine()
	  mds = mds:gsub( "u", "" )
    end
  elseif key == 31 then
    if s == false then
      s = true
      term.setCursorPos(1,8)
      print"Special"
	  mds = mds .. 's'
    else
      s = false
      term.setCursorPos(1,8)
      term.clearLine()
	  mds = mds:gsub( "s", "" )
    end
  elseif key == 49 then
    if n == false then
      n = true
      term.setCursorPos(1,9)
      print"Number"
	  mds = mds .. 'n'
    else
      n = false
      term.setCursorPos(1,9)
      term.clearLine()
	  mds = mds:gsub( "n", "" )
    end
  elseif key == 38 then
    if l == false then
      l = true
      term.setCursorPos(1,10)
      print"Lower"
	  mds = mds .. 'l'
    else
      l = false
      term.setCursorPos(1,10)
      term.clearLine()
	  mds = mds:gsub( "l", "" )
    end
  elseif key == 28 and ( l or n or s or u ) then -- makes sure atleast one of the options is ticked
    break
  end
end

Because on line 85 (or something) it uses mds which isn't defined.
I made a few changes (the above) and it works perfectly.

I will also suggest having a limit of the password length, because entering 3000 is insane lol
Conn332 #3
Posted 24 February 2013 - 02:23 PM
Pretty cool, definitely makes some random-pseudo passwords :)/>

But it does not work because you haven't defined mds.

You need to change the part where you select Upper/lower/special/number to this:
Spoiler
mds = ""
while true do
  event, key = os.pullEvent("key")
  if key == 22 then
	if u == false then
	  u = true
	  term.setCursorPos(1,7)
	  print"Upper"
	  mds = mds .. 'u'
	else
	  u = false
	  term.setCursorPos(1,7)
	  term.clearLine()
	  mds = mds:gsub( "u", "" )
	end
  elseif key == 31 then
	if s == false then
	  s = true
	  term.setCursorPos(1,8)
	  print"Special"
	  mds = mds .. 's'
	else
	  s = false
	  term.setCursorPos(1,8)
	  term.clearLine()
	  mds = mds:gsub( "s", "" )
	end
  elseif key == 49 then
	if n == false then
	  n = true
	  term.setCursorPos(1,9)
	  print"Number"
	  mds = mds .. 'n'
	else
	  n = false
	  term.setCursorPos(1,9)
	  term.clearLine()
	  mds = mds:gsub( "n", "" )
	end
  elseif key == 38 then
	if l == false then
	  l = true
	  term.setCursorPos(1,10)
	  print"Lower"
	  mds = mds .. 'l'
	else
	  l = false
	  term.setCursorPos(1,10)
	  term.clearLine()
	  mds = mds:gsub( "l", "" )
	end
  elseif key == 28 and ( l or n or s or u ) then -- makes sure atleast one of the options is ticked
	break
  end
end

Because on line 85 (or something) it uses mds which isn't defined.
I made a few changes (the above) and it works perfectly.

I will also suggest having a limit of the password length, because entering 3000 is insane lol
Oh ok, That was from an earlier version of the code where mds was a place holder for all the modes in plain text. I'll get right on fixing that thanks for the help!
Bubba #4
Posted 24 February 2013 - 04:07 PM
I like this. I can imagine this coming in pretty handy now that rednet is no longer secure.

You may want to fix your pastebin link though. The one that is linked is different from the text on the post.


I do have a bit of advice:
I noticed that you defined all of the characters manually. That's not necessary. There is a wonderful function called string.char(num) which converts numbers into characters.

Here's the breakdown (note that some characters aren't supported by CC yet. 32-126 and things like tab work fine though)
Spoiler

Another thing you may want to do is let the user easily specify the filename to save under. I downloaded the program as pass the first time and it was then overwritten :)/>
Conn332 #5
Posted 25 February 2013 - 03:46 AM
I like this. I can imagine this coming in pretty handy now that rednet is no longer secure.

You may want to fix your pastebin link though. The one that is linked is different from the text on the post.


I do have a bit of advice:
I noticed that you defined all of the characters manually. That's not necessary. There is a wonderful function called string.char(num) which converts numbers into characters.

Here's the breakdown (note that some characters aren't supported by CC yet. 32-126 and things like tab work fine though)
Spoiler

Another thing you may want to do is let the user easily specify the filename to save under. I downloaded the program as pass the first time and it was then overwritten :)/>

Wow, that is really helpful for this code, Thank you! I'll get right to fixing the filename and see what I can do for string.char() :)/>
Mackan90096 #6
Posted 13 March 2013 - 01:54 AM
Mind if i use this in my os?
Conn332 #7
Posted 13 March 2013 - 09:34 AM
Mind if i use this in my os?
not at all :)/>
Mackan90096 #8
Posted 14 March 2013 - 02:20 AM
Mind if i use this in my os?
not at all :)/>
Thanks