23 lines
941 B
Lua
23 lines
941 B
Lua
|
|
-- "Сгенерируй пароль 16 символов" → secure password (alphanumeric + symbols)
|
||
|
|
-- Copies result to clipboard, speaks length only (so it's not echoed).
|
||
|
|
local phrase = (jarvis.context.phrase or ""):lower()
|
||
|
|
local n = tonumber(phrase:match("(%d+)")) or 16
|
||
|
|
if n < 6 then n = 6 end
|
||
|
|
if n > 64 then n = 64 end
|
||
|
|
|
||
|
|
local pool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*-_=+"
|
||
|
|
math.randomseed(os.time() + (jarvis.context.time.minute or 0) * 1000)
|
||
|
|
|
||
|
|
local pw = {}
|
||
|
|
for _ = 1, n do
|
||
|
|
local idx = math.random(1, #pool)
|
||
|
|
table.insert(pw, pool:sub(idx, idx))
|
||
|
|
end
|
||
|
|
local password = table.concat(pw)
|
||
|
|
|
||
|
|
jarvis.system.clipboard.set(password)
|
||
|
|
jarvis.system.notify("Пароль (" .. n .. " символов)", "Скопирован в буфер обмена")
|
||
|
|
|
||
|
|
-- Speak length only, never the password itself.
|
||
|
|
return jarvis.cmd.ok(string.format("Пароль на %d символов в буфере.", n))
|