diff --git a/centralLoggingSystem/loggerClient.lua b/centralLoggingSystem/loggerClient.lua new file mode 100644 index 0000000..2ba278e --- /dev/null +++ b/centralLoggingSystem/loggerClient.lua @@ -0,0 +1,32 @@ +local loggerClient = {} + +settings.define("logger.AES.key", { + description = "AES key used for encryption", + type = "number" +}) + +settings.define("logger.modemSide", { + description = "The side of the modem (for pocket computers this is 'back')", + type = "string" +}) + +settings.define("logger.channel", { + description = "The channel used", + type = "number" +}) + +local AES = require("/AES") + +local key = settings.get("logger.AES.key") or error("No AES Key set") +local modemSide = settings.get("logger.modemSide") or error("No modem found") +local channel = settings.get("logger.channel") or error("No channel set") + +local modem = peripheral.wrap(modemSide) + +function loggerClient.log(sender, message) + local message = textutils.serialize({sender = sender, message = message}) + local encrypted = AES.ECB_256(AES.encrypt, key, message) + modem.transmit(channel, channel, encrypted) +end + +return loggerClient diff --git a/centralLoggingSystem/readme.md b/centralLoggingSystem/readme.md index 357262b..44aea49 100644 --- a/centralLoggingSystem/readme.md +++ b/centralLoggingSystem/readme.md @@ -11,6 +11,18 @@ Logs data sent to it by various computers and prints it on printed pieces of pap 7. Choose a channel number and set the channel by changing the `channel` variable. # Client Setup +1. download `loggerClient.lua` and put it on your computer. +2. attach a modem to the computer and note what side it is on. +3. set the settings `logger.AES.key`, `logger.modemSide` and `logger.channel`. +4. download the AES dependency and put it in the root directory. +5. use `require` to include to use this library. + +## Example +```lua +local logger = require("/loggerClient") + +logger.log("testLogger", "this is a test log") +``` # Dependencies - [Lua_AES](https://github.com/idiomic/Lua_AES)