mirror of
https://git.phreedom.club/localhost_frssoft/fediauth.git
synced 2025-02-16 22:34:31 +00:00
add otp.generate_secret()
This commit is contained in:
parent
02f90efcaa
commit
10e82093b6
|
@ -164,3 +164,12 @@ function otp.create_qr_png(data)
|
||||||
|
|
||||||
return minetest.encode_png(width, height, png_data, 2)
|
return minetest.encode_png(width, height, png_data, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function otp.generate_secret()
|
||||||
|
local buf = minetest.sha1("" .. math.random(10000), true)
|
||||||
|
local s = ""
|
||||||
|
for i=1,20 do
|
||||||
|
s = s .. string.char(string.byte(buf, i))
|
||||||
|
end
|
||||||
|
return s
|
||||||
|
end
|
|
@ -58,3 +58,9 @@ mtt.register("otp.create_qr_png", function(callback)
|
||||||
f:close()
|
f:close()
|
||||||
callback()
|
callback()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
mtt.register("otp.generate_secret", function(callback)
|
||||||
|
local s = otp.generate_secret()
|
||||||
|
assert(#s == 20)
|
||||||
|
callback()
|
||||||
|
end)
|
Loading…
Reference in a new issue