function main() while true do ::Start:: -- Check for inserted floppy. term.setCursorPos(1,1) term.clear() monitor.clear() print("Bitte Bankkarte in Laufwerk stecken.") term.setCursorPos(1,3) print("Für eine neue karte:") term.setCursorPos(3,4) print("1. Karte aus box holen.") term.setCursorPos(3,5) print("2. Karte in Laufwerk schieben.") local event, side = os.pullEvent("disk") if ~login() then term.setCursorPos(1,1) term.clear() monitor.clear() print("Bankkarte ungültig!") drive.eject("front") sleep(3) goto Start end -- Let user choose between (überweisen, karte erstellen). term.setCursorPos(1,1) term.clear() monitor.clear() term.setBackgroundColor(4096) term.setCursorPos(1,1) print("Überweisen") term.setCursorPos(1,2) print("Placeholder") term.setBackgroundColor(32768) while true do local event, side, x, y = os.pullEvent() if event == "monitor_touch" then if y == 1 then elseif y == 2 then break elseif y == 3 then break end end end drive.eject("front") end end function login() local name = "" local id = "" local password = "" -- Check who's disk it is. name = drive.getLabel(drive_pos) -- Get unique id from disk. id = drive.getID(drive_pos) -- Read bank card and decrypt password. if ~fs.exists(card_name) then return false end local file = fs.open(card_name, "r") password = encryption.Decrypt(file.readLine(), 5) -- get 4 digit pin, password and username from database. file = fs.open(database_path .. name .. ".txt") local client_name = file.readLine() local client_id = encryption.Decrypt(file.readLine(), 4) local client_pin = encryption.Decrypt(file.readLine(), 4) local client_password = encryption.Decrypt(file.readLine(), 4) -- compare password and username with database. if password ~= client_password or name ~= client_name then return false end -- Request 4 digit pin from user. for i = 1, 3 do local pin = "" local pin_char = "" term.clear() monitor.clear() term.setCursorPos(1,1) term.clearLine() print("Gib deine PIN ein: " .. pin_char) term.setBackgroundColor(4096) term.setCursorPos(1,2) print("789") term.setCursorPos(1,3) print("456") term.setCursorPos(1,4) print("123") term.setCursorPos(2,5) print("0") term.setBackgroundColor(32768) local event, side, x, y = os.pullEvent() for i = 1, 4 do if event == "monitor_touch" then if x == 2 and y == 5 then pin = pin + "0" pin_char = pin_char + "*" elseif x == 1 and y == 2 then pin = pin + "7" pin_char = pin_char + "*" elseif x == 2 and y == 2 then pin = pin + "8" pin_char = pin_char + "*" elseif x == 3 and y == 2 then pin = pin + "9" pin_char = pin_char + "*" elseif x == 1 and y == 3 then pin = pin + "4" pin_char = pin_char + "*" elseif x == 2 and y == 3 then pin = pin + "5" pin_char = pin_char + "*" elseif x == 3 and y == 3 then pin = pin + "6" pin_char = pin_char + "*" elseif x == 1 and y == 4 then pin = pin + "1" pin_char = pin_char + "*" elseif x == 2 and y == 4 then pin = pin + "2" pin_char = pin_char + "*" elseif x == 3 and y == 4 then pin = pin + "3" pin_char = pin_char + "*" end end end if pin == client_pin then term.clear() monitor.clear() print("Willkommen " .. name) sleep(3) return true end end end function send() -- Request amount and receiver. -- Send Money if available. end -- Card data structure: -- Password (Enc.5) -- Database data structure: -- Username -- ID (Enc.4) -- PIN (Enc.4) -- Password (Enc.4) -- Cash os.loadAPI("encryption.lua") monitor = peripheral.wrap("top") monitor.setTextScale(1) drive = peripheral.wrap("bottom") drive_pos = "right" card_name = "disk/bank.txt" database_path = "disk/users/" database = peripheral.wrap("back") main()