1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-31 20:09:02 +00:00

Standardize random string generation on stdnse.generate_random_string

This commit is contained in:
dmiller
2015-02-25 05:06:08 +00:00
parent f6733b2d89
commit db717c7543
10 changed files with 15 additions and 119 deletions

View File

@@ -175,22 +175,8 @@ local special_passwords = { USERNAME, USERNAME_REVERSED }
--@param set (optional) The set of letters to choose from. Default: upper, lower, numbers, and underscore.
--@return The random string.
local function get_random_string(length, set)
if(length == nil) then
length = 8
end
if(set == nil) then
set = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"
end
local str = ""
for i = 1, length, 1 do
local random = math.random(#set)
str = str .. string.sub(set, random, random)
end
return str
return stdnse.generate_random_string(length or 8,
set or "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_")
end
---Splits a string in the form "domain\user" into domain and user.