Advertisement
TheOddByte

[ComputerCraft][Program] PassGen

Jun 21st, 2013
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. --[[
  2.     [Program] PassGen
  3.     @version 1.0, 09/02/2014, HK98
  4.     @author Hellkid98, HK98
  5. --]]
  6.  
  7.  
  8. local args = {...}
  9. --# Checking for errors
  10. if #args < 2 then
  11.     error( "Usage: <Lenght> <Output file>", 0 )
  12. end
  13. if not tonumber( args[1] ) then
  14.     error( "Usage: <Lenght> <Output file>", 0 )
  15. end
  16. if fs.exists( args[2] ) then
  17.     error( "File exists!\nUsage: <Lenght> <Output file>", 0 )
  18. end
  19.  
  20.  
  21. --# All the available characters
  22. local characters = {
  23.     "A","B","C","D","E","F","G","H","I","J","K","L",
  24.     "M","N","O","P","Q","R","S","T","U","V","W","X",
  25.     "Y","Z","0","1","2","3","4","5","6","7","8","9",
  26. }
  27.  
  28.  
  29. local str = ""
  30. for i = 1, tonumber( args[1] ) do
  31.     local s = characters[math.random( 1, #characters )]
  32.     if math.random(1,2) % 2 == 0 then
  33.         s = string.lower( s )
  34.     end
  35.     str = str .. s
  36. end
  37. local f = fs.open( args[2], "w" )
  38. f.writeLine( str )
  39. f.close()
  40. print( "Password generated: " .. str )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement