Advertisement
Guest User

add_user.lua

a guest
May 11th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. require("/scripts/auth/sha256")
  2.  
  3. print("New username: ")
  4. local username = read()
  5. print("New password: ")
  6. local password = digestStr(read("*"))
  7.  
  8. print("Root password: ")
  9. local root = digestStr(read("*"))
  10.  
  11. for line in io.lines("/.password") do
  12.  local i = string.find(line, "|")
  13.  if (i ~= nil and string.sub(line, 1, i-1) == "jo") then
  14.   if string.sub(line, i+1) == root then
  15.    local file = io.open("/.password", "a+")
  16.    file:write(username.."|"..password)
  17.    file:close()
  18.    print("User added successfully!")
  19.    return
  20.   else
  21.    print("Wrong root password")
  22.    return
  23.   end
  24.  end
  25. end
  26. print("No root user present")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement