Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPullEvent = os.pullEvent os.pullEvent = os.pullEventRaw local sha256 = require("sha256") print("Auto-updating..") fs.delete("/startup.lua")
- shell.run("wget https://raw.githubusercontent.com/Apethesis/SimplePass/main/startup.lua /startup.lua") os.sleep(1) local chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
- local function makeSalt(len) local salt = "" for i = 1, len do local j = math.random(1, #chars) salt = salt .. chars:sub(j,j) end return salt end if not fs.exists("/.spass/password.txt") then
- while true do term.clear() term.setCursorPos(1,1) print("Please enter your account name:") term.write("[") term.setCursorPos(11,2) term.write("]") term.setCursorPos(2,2)
- local user = read() print("Please create a new password:") term.write("[") term.setCursorPos(11,4) term.write("]") term.setCursorPos(2,4) local newPass = read("\007")
- print("Please confirm your password:") term.write("[") term.setCursorPos(11,6) term.write("]") term.setCursorPos(2,6) local confirm = read("\007") if newPass == confirm then
- local f = fs.open("/.spass/password.txt","w") local salt = makeSalt() local writepass = string.char(unpack(sha256.pbkdf(newPass, salt))) f.writeLine(writepass)
- f.writeLine(salt) f.close() local u = fs.open("/.spass/user.txt","w") u.write(user) u.close() term.clear() term.setCursorPos(1,1) break else print("Passwords did not match!") os.sleep(1)
- end end else while true do term.clear() term.setCursorPos(1,1) print("Please enter your password:") term.write("[") term.setCursorPos(11,2) term.write("]") term.setCursorPos(2,2)
- local ps = fs.open("/.spass/password.txt","r") local u = fs.open("/.spass/user.txt","r") local crpassword = ps.readLine() local salt = ps.readLine() local password = read("\007") local hash = string.char(unpack(sha256.pbkdf2(password, salt)))
- local user = u.readAll() if hash == crpassword then print("Welcome " .. user) ps.close() u.close() os.pullEvent = oldPullEvent break else print("Incorrect Password.")
- os.sleep(1) end end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement