this API was born out of a void i found while writing a program. there wasn't an api that fit my needs, so i made one, and now i'm going to share it.

The RedAuth API is an authentication API for use in programs where you want to be able to have usernames and password for each user to login with to the perform a specific action.

it comprises of just 3 functions (for now):

1. doLogin
2. adduser
3. deluser
  1. doLogin: This is where the magic happens. this function will take a username and password passed to it and validate it against those in a file. it returns 4 values. success, result, username and option.
  2. success: is returned as a boolean. true if login succeeded, false if it didn't. (also returns false if a password file doesn't exist, more on that later) result: returns additional info about what happened. e.g. when login succeeds, it returns "login succeeded" username: returns the username you passed to it if login succeeded option: this is an optional variable, to which you can assign anything you want. (more on this later too) in the event that a password file doesn't exist, one will be created, containing the username "user" and the password "test" The function will return false with result "No password file found, Created one.\nlogin with 'user:test'"
  3. adduser: this takes 3 arguments, "username", "password" and "option"
  4. the "option" parameter is optional. if you don't specify something for it, it will be set to "none" the "option" parameter is also returned on successful login, so you can use it for whatever you want.
  5. deluser: this takes just 1 argument, username and returns 2 values, success and result
  6. simply pass a username to this function and if it exists, it will be deleted and the function will return true with result: "user: '" .. username .. "' removed" Else it will return false with result: "No such user exists"
Pastebin link: nVJgeMBx

Feel free to use this in any way you see fit. suggest improvements or rewrite it completely if you want :)/>
if you find any problems, feel free to post them here or suggest fixes.

PS: i'd Like to say thank you to @darkrising for helping with some of the code and the file saving functions