GetPasswordDifficulty: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Code) |
||
| Line 28: | Line 28: | ||
return strong | return strong | ||
end | end | ||
</syntaxhighlight | </syntaxhighlight | ||
==Example== | ==Example== | ||
Revision as of 17:12, 7 April 2020
This function checks the password difficulty
Syntax
int getPasswordDifficulty ( string password )
Required arguments
- password: The password whose difficulty you want to check
Return
Returns a value from 1
Code
function getPasswordDifficulty(password)
assert(type(password) == "string", "Bad argument @ getPasswordDifficulty [string expected, got " .. tostring(password) .. "]" )
local strong = 0
if string.find(password, "[0-9]") then
strong = strong + 1
end
if string.find(password, "%u") then
strong = strong + 1
end
return strong
end
</syntaxhighlight
==Example==
<section name="Example" class="client" show="true">
After using the command with a password, it returns its difficulty
<syntaxhighlight lang="lua">
function difficulty(commandName, password)
if not password then
return outputChatBox("Type password")
end
outputChatBox(getPasswordDifficulty(password))
end
addCommandHandler("difficulty", difficulty)
</section>
Author: Liberty