Recently I created a simple Username and Password login system… the code will be below. I want to know how I can create some sort of database / server link as to allow for people to create their own Users/Passwords. At the moment everything is hard coded… how can I create a server link + encryption?
Note: I have not used rednet before and I know it will require the use of it…. plus I never really bother with the layout when using Computercraft so may be a tad messy :P/>
Here is my code:
os.pullEvent = os.pullEventRaw
term.clear()
term.setCursorPos(12, 5)
term.setTextColor(10)
term.write("Please enter your username:")
term.setCursorPos(14, 6)
term.setTextColor(1)
user = io.read()
userID = 0
while userID < 1 do
term.clearLine()
if user == "MrMark2202" then
userID = 1
term.clearLine()
term.setCursorPos(6, 5)
term.setTextColor(10)
term.write("Welcome Mark. Please enter your password:")
term.setCursorPos(14, 6)
term.clearLine()
term.setTextColor(1)
password = io.read()
elseif user == "ShowKitten" then
userID = 2
term.clearLine()
term.setCursorPos(6, 5)
term.setTextColor(10)
term.write("Welcome Tom. Please enter your password:")
term.setCursorPos(14, 6)
term.setTextColor(1)
term.clearLine()
password = io.read()
elseif user == "debug" then
userID = 3
else
term.setCursorPos(6, 5)
term.clearLine()
term.setTextColor(10)
term.write("Incorrect username, please try again:")
term.setCursorPos(14, 6)
term.setTextColor(1)
term.clearLine()
user = io.read()
term.clearLine()
end
end
i = 4
while i > 1 do
if user == "MrMark2202" and password == "lolpassword" or user == "ShowKitten" and password == "lolpassword2 then
term.clear()
term.setCursorPos(10, 5)
term.setTextColor(3)
term.write("Enjoy your stay.")
redstone.setOutput("back", true)
sleep(1)
os.shutdown()
elseif user == "debug" then
i = 0
else
i = i - 1
term.clearLine()
term.setCursorPos(6, 5)
term.setTextColor(10)
term.write("Incorrect password. Attempts remaining: "..i)
term.setCursorPos(14, 6)
term.clearLine()
term.setTextColor(1)
password = io.read()
end
end
if i == 1 then
term.setCursorPos(6, 5)
term.setTextColor(10)
term.write("Incorrect password, Attempts remaining: 0")
term.setCursorPos(10, 6)
term.write("System shutting down")
sleep(3)
os.shutdown()
elseif i == 0 then
term.setCursorPos(6, 5)
term.setTextColor(10)
term.write("System Overide. Core access granted")
term.clear()
term.setCursorPos(1, 1)
end
The passwords were changed to lolpassword and lolpassword2 for security sake.