Advertisement
Guest User

basic_auth

a guest
Feb 14th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. -- Prompts user for a password
  2. function getPass()
  3.   print("Password:")
  4.   local password = read()
  5.   return password
  6. end
  7.  
  8. -- Prompts user for a username
  9. function getUser()
  10.   print("Username:")
  11.   local username = read()
  12.   return username
  13. end
  14.  
  15. -- Performs a linear search on an array
  16. function linearSearch(key, arr)
  17.   local isFound = false
  18.   local itemIndex = -1
  19.   for i=0,table.getn(arr) do
  20.     if arr[i] == key then
  21.       isFound = true
  22.       itemIndex = i
  23.     end
  24.   end
  25.   return {isValid,itemIndex}
  26. end
  27.  
  28. function validate(table, *input)
  29.   local isValid = false
  30.   local valTable = {}
  31.   if table.getn(table) == table.getn(input)
  32.     --WIP
  33.     valTable[#valTable+1] = linearSearch(input[k], table[i][j])
  34.   end
  35. end
  36.  
  37. -- initilizer method
  38. function main()
  39.   local username = ""
  40.   local password = ""
  41.  
  42.   username = getUser()
  43.   password = getPass()
  44.   userTable = {"root","bob"}
  45.   passTable = {"password","cookie"}
  46.   userpassTable = {userTable,passTable}
  47.   print(validateUserpass(userpassTable,username,password))
  48.   --password = getPassword()
  49. end
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement