Advertisement
osmarks

DoorCardGen

Jan 2nd, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local function fetch(URL)
  2.     local h = http.get(URL)
  3.     local text = h.readAll()
  4.     h.close()
  5.     return text
  6. end
  7.  
  8. local function fwrite(file, data)
  9.     local f = fs.open(file, "w")
  10.     f.write(data)
  11.     f.close()
  12. end
  13.  
  14. local ECC = loadstring(fetch "https://pastebin.com/raw/Sc0DU3rA")() "ecc"
  15.  
  16. local function hexize(key)
  17.     local out = ""
  18.     for _, v in pairs(key) do
  19.         out = out .. string.format("%.2x", v)
  20.     end
  21.     return out
  22. end
  23.  
  24. write "Clearance level: "
  25. local level = tonumber(read())
  26.  
  27. local pub, priv = ECC.keypair()
  28. fwrite("disk/keyfile", hexize(priv))
  29. print "Keyfile written to disk"
  30.  
  31. print "Please add the linked text to your door configuration."
  32. fwrite(".temp", string.format([[["%s"] = %d]], hexize(pub), level))
  33. shell.run "pastebin put .temp"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement