Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("/.apis/sha")
- local w,h = term.getSize()
- function getPass()
- local inTerm = window.create(term.current(),w/2-6,h/2,13,1,true)
- local oldTerm = term.redirect(inTerm)
- term.setBackgroundColor(2^7)
- term.write(" ")
- term.setCursorPos(1,1)
- local out = read("*")
- term.redirect(oldTerm)
- term.clear()
- term.setCursorPos(1,1)
- return out
- end
- local passHashHandle = fs.open("/SecuritySystem/.passhash","r")
- local passHash = passHashHandle.readAll()
- passHashHandle.close()
- while true do
- term.clear()
- term.setCursorPos(math.ceil((w-17)/2),h/2-2)
- term.write("Current Password:")
- local input = getPass()
- if sha.sha256(input)==passHash then
- term.clear()
- term.setCursorPos(math.ceil((w-13)/2),h/2-2)
- term.write("New Password:")
- local newpass = getPass()
- term.setCursorPos(math.ceil((w-16)/2),h/2-2)
- term.write("Repeat Password:")
- local input = getPass()
- if newpass == input then
- local file = fs.open("/SecuritySystem/.passhash","w")
- file.write(sha.sha256(newpass))
- file.close()
- term.setCursorPos(math.ceil((w-16)/2),h/2)
- term.write("Password changed")
- sleep(2)
- break
- else
- term.setCursorPos(math.ceil((w-21)/2),h/2)
- term.write("Passwords don't match")
- sleep(2)
- end
- else
- term.setCursorPos(math.ceil((w-8)/2),h/2)
- term.write("Incorrect!")
- sleep(2)
- end
- end
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment