2020-08-24 05:20:42 +00:00
|
|
|
local SHA = require("opus.crypto.sha2")
|
|
|
|
|
2022-12-28 09:22:57 +00:00
|
|
|
local acceptableCharacters = {}
|
|
|
|
for c = 0, 127 do
|
|
|
|
local char = string.char(c)
|
|
|
|
-- exclude potentially ambiguous characters
|
2022-12-28 15:22:20 +00:00
|
|
|
if char:match("[1-9a-zA-Z]") and char:match("[^OIl]") then
|
2022-12-28 09:22:57 +00:00
|
|
|
table.insert(acceptableCharacters, char)
|
|
|
|
end
|
|
|
|
end
|
2020-08-24 05:20:42 +00:00
|
|
|
local acceptableCharactersLen = #acceptableCharacters
|
|
|
|
local password = ""
|
|
|
|
|
2022-12-28 09:22:57 +00:00
|
|
|
for i = 1, 10 do
|
2020-08-24 05:20:42 +00:00
|
|
|
password = password .. acceptableCharacters[math.random(acceptableCharactersLen)]
|
|
|
|
end
|
|
|
|
|
|
|
|
os.queueEvent("set_otp", SHA.compute(password))
|
|
|
|
|
2022-12-28 09:22:57 +00:00
|
|
|
print("This allows one other device to permanently gain access to this device.")
|
|
|
|
print("Use the trust settings in System to revert this.")
|
|
|
|
print("Your one-time password is: " .. password)
|