Posted 09 January 2017 - 10:59 AM
Hi, I'm trying to create a login system which saves the passwords to a file. I also want to make something to encrypt the saved password, but I don't know how. Here's my code:
term.clear()
term.setCursorPos(1,1)
local UsrData = fs.exist("/Users/"..UsrName"")
print("Please login:")
local UsrName = read()
print("Checking if"..UsrName"exist...")
if UsrData == true then
fs.open("/Users/"..UsrName,"a")
local fileData = {}
local line = file.reaadLine()
repeat
table.insert(fileData,line)
line = file.readLine()
until line == nil
file.close()
local UserPass = fileData[1]
print(..UsrName", please give me your password")
input = read()
if input == UserPass then
print("You have succesfully logged in!")
term.clear()
term.setCursorPos(1,1)
else
print("Wrong password!")
sleep(1)
shell.run("/login")
else
term.clear()
term.setCursorPos(1,1)
print("I don't know you "..UsrName"")
print("Please, select a password to save:")
password = read()
local file = fs.open("/Users/"..UsrName,"a")
file.writeLine(password)
file.close()
print("I saved your account "..UsrName"")
print("Please login!!")
sleep(1)
shell.run("/login")
end
Edited on 09 January 2017 - 10:05 AM