Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- if not fs.exists("aes.lua") then
- shell.run("wget", "https://gist.githubusercontent.com/LolloDev5123/9409c11864934a7f08c7a7d65295ddad/raw/5b93d8ed7156ad81b21abda1d1fba4a34a5730c9/AES.lua", "aes.lua")
- end
- if not fs.exists("encode.lua") then
- shell.run("pastebin", "get", "ksk0HmaJ", "encode.lua")
- end
- local aes = require("aes")
- local encode = require("encode")
- local function encode(bytes)
- return string.char(table.unpack(bytes))
- end
- local function findDisk()
- local periphs = peripheral.getNames()
- for k,v in ipairs(periphs) do
- local type = peripheral.getType(v)
- if type == "drive" then
- return true, v
- end
- end
- return false
- end
- local function run()
- if args[1] == "create" then
- local diskFound, name = findDisk()
- if not diskFound then
- print("A disk drive must be attached to use this feature")
- return
- end
- if not disk.isPresent(name) then
- print("A disk must be inserted into the disk drive")
- return
- end
- disk.setLabel(name, "Encryption Key")
- local mountPath = disk.getMountPath(name)
- local key = aes.GenerateRandomKey()
- local encoded = encode(key)
- local file = fs.open(mountPath .. "/key.txt", "w")
- file.write(encoded)
- file.close()
- print("Created key on disk")
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement