Commit 4704fbb5 authored by Danny SMc's avatar Danny SMc 🎧

Update uLock

parent a313b8b4
-- Simple Door Lock
-- Created by DannySMc
-- Version 1.1
-- Version 1.2
-- Platform: Lua Virtual Machine
-- Security Method
......@@ -11,7 +11,7 @@ os.pullEvent = os.pullEventRaw
if fs.exists("uapi") == false then
print("Missing uAPI!")
print("Attempting to download..")
getGit = http.get("https://raw.github.com/dannysmc95/uprograms/master/uAPI")
getGit = http.get("https://raw.github.com/dannysmc95/uprograms/master/uapi")
getGit = getGit.readAll()
file = fs.open("uapi", "w")
file.write(getGit)
......@@ -44,11 +44,10 @@ if fs.exists(".uLockConf") == false then
term.write("Program Name: ")
strProgName = read()
-- Encrypt Password
strPasswordEncrypted = uapi.encrypt(strPassword, 1)
strPassword = uapi.checksum(strPassword, 1000)
-- Create Configuration File
uapi.saveConfig({['progName']=strProgName, ['terminalName']=strName, ['redSide']=strSide, ['redPulse']=strPulse, ['lockPassword']=strPasswordEncrypted}, ".uLockConf")
uapi.saveConfig({['progName']=strProgName, ['terminalName']=strName, ['redSide']=strSide, ['redPulse']=strPulse, ['lockPassword']=strPassword}, ".uLockConf")
-- Startup File
term.setCursorPos(1,14)
......@@ -59,7 +58,6 @@ if fs.exists(".uLockConf") == false then
startupAnswer = read()
until ((startupAnswer == "YES") or (startupAnswer == "NO"))
-- Create startup file
if startupAnswer == "YES" then
startFile = fs.open("startup", "w")
startFile.writeLine('os.loadAPI("uapi")')
......@@ -78,9 +76,8 @@ if fs.exists(".uLockConf") == false then
os.reboot()
end
-- Load Configuration File and Decryption
-- Load Configuration File
config = uapi.loadConfig(".uLockConf")
strPasswordDecrypted = uapi.decrypt(config.lockPassword, 1, true)
-- Password Lock Program
uapi.cs()
......@@ -94,18 +91,18 @@ uapi.resetCol()
term.setCursorPos(1,10)
term.write("> Password: ")
password = read("*")
if password == strPasswordDecrypted then
term.setCursorPos(1,10)
print("Password Correct!")
password = uapi.checksum(password, 1000)
if password == config.lockPassword then
term.setCursorPos(1,11)
print("> Password Correct!")
rs.setOutput(config.redSide, true)
sleep(config.redPulse)
rs.setOutput(config.redSide, false)
sleep(0.5)
os.reboot()
else
term.setCursorPos(1,10)
print("Password Incorrect!")
term.setCursorPos(1,11)
print("> Password Incorrect!")
sleep(1.5)
os.reboot()
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment