This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
lzRipTide3zl's profile picture

Lockout API

Started by lzRipTide3zl, 11 April 2013 - 03:31 PM
lzRipTide3zl #1
Posted 11 April 2013 - 05:31 PM
Lockout API

Lockout API. An API that makes it easier to make a security program.

Lockout API is a very simple API to use. Basicly, run the functions and they will do all of it for you. The only thing you need to do is the Interface.

Install:
Spoiler1. Copy the API from the spoiler.

2. paste it into a text editor
3. Save it to %appdata%/.minecraft/mods/computercraft/lua/rom/apis
4. Launch Minecraft

Usage:
Spoiler
lockout.usernameFile("username")
lockout.passwordFile("password")
lockout.denyTerminate()
lockout.promptUser()
lockout.promptPass()
lockout.check()
if lockout.check() == true then
  print ("Login successful!")
else
  print ("Username or password incorrect")
  sleep(1)
  shell.run("clear")
  shell.run("startup")
end

Also make sure to make a file for username and password!

Functions:
Spoilerversion: Returns lockout version

usernameFile("usernamefile"): Opens the username file to be handled.
passwordFile("passwordfile"): Opens the password file to be handled.
denyTerminate(): Disables Ctrl + t.
promptUser(): prompts with "Enter Username: "
promptPass(): prompts with "Enter Password: "
check(): Returns true if user == username and pass == password


API:
Spoiler
function version()
	return "0.0.1"
end
function usernameFile(file)
	usernameFile = fs.open(file, "r")
	username = usernameFile.readLine()
end
function passwordFile(file)
	passwordFile = fs.open(file, "r")
	password = passwordFile.readLine()
end
function denyTerminate()
	os.pullEvent = os.pullEventRaw
end
function promptUser()
	write("Enter Username: ")
	user = read()
end
function promptPass()
	write("Enter Password: ")
	pass = read("*")
end
function check()
	if user == username and pass == password then
		return true
	else
		return false
	end
end
Rax #2
Posted 19 April 2013 - 02:53 AM
Username & Password File?
Dave-ee Jones #3
Posted 15 May 2013 - 04:07 AM
Maybe you should make the files hidden? It would be easy to hack otherwise. It is a pretty good API though, thinking of adding a few lock functions into QuickTils.
lzRipTide3zl #4
Posted 17 July 2013 - 09:36 PM
Maybe you should make the files hidden? It would be easy to hack otherwise. It is a pretty good API though, thinking of adding a few lock functions into QuickTils.
denyTerminate() disallows Ctrl + T termination. If the function is called it wont be hackable unless if someone installed a diskdrive and ran a startup program.