This should do what you want. I didn't test it so it may not work. Just reply with the error message if it doesn't work.
local component = require("component")
local r = component.redstone
local term = require("term")
local text = require("text")
---- config section
local password = {
pw_open = "openMe",
pw_close = "closeMe"
}
local side = 5 --side of the door
-----
local open = false
local input_password
local function checkPassword(i_password)
if (i_password == password.pw_open & open == false) then
return true
elseif (i_password == password.pw_close & open == true) then
return true
else
return false
end
end
term.clear()
while true do
print("Please enter the password:")
input_password = text.trim(term.read({pwchar = "*"}) or "")
if (checkPassword(input_password)) then
if (open == true) then
-- Close the door if open.
print("Closing the door.")
r.setOutput(side, 15)
else
-- Open the door if closed.
print("Opening the door.")
r.setOutput(side, 0)
end
else
print("Password was wrong, try again")
end
end