mirror of
https://github.com/kepler155c/opus
synced 2024-11-15 05:04:50 +00:00
a77deb72ec
This commit adds a one-time password system. Users can generate passwords by using the `genotp` command (or manually queuing a set_otp event with the SHA-256 hash of the one-time password they want to set) and these passwords will be valid, along with the normal password, either until the computer shuts down (or the net daemon is killed), a new one-time password is generated, or the one-time password is used.
14 lines
535 B
Lua
14 lines
535 B
Lua
local SHA = require("opus.crypto.sha2")
|
|
|
|
local acceptableCharacters = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
|
|
local acceptableCharactersLen = #acceptableCharacters
|
|
|
|
local password = ""
|
|
|
|
for _i = 1, 8 do
|
|
password = password .. acceptableCharacters[math.random(acceptableCharactersLen)]
|
|
end
|
|
|
|
os.queueEvent("set_otp", SHA.compute(password))
|
|
|
|
print("Your one-time password is: " .. password) |