Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function user_exists(name)
- local f = io.open("users/" .. name, "r")
- if f then
- f:close()
- return true
- else
- return false
- end
- end
- function create_account(name, passwd)
- local file
- if not user_exists(name) then
- file = io.open("users/" .. name, "w")
- file:write(passwd)
- file:close()
- return true
- end
- return false
- end
- function verify_account(name, passwd)
- local f, str
- if user_exists(name) then
- f = io.open("users/" .. name, "r")
- str = f:read("*a")
- f:close()
- if str == passwd then
- return true
- end
- end
- return false
- end
- create_account("chesno_a", "zizi")
- create_account("tangeek", "mdp")
- print(verify_account("tangeek", "mdp"))
- print(verify_account("tangeek", "mdpaa"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement