mirror of
https://github.com/nmap/nmap.git
synced 2025-12-15 20:29:03 +00:00
Standardize random string generation on stdnse.generate_random_string
This commit is contained in:
@@ -738,23 +738,9 @@ Util = {
|
||||
-- @param set (optional) The set of letters to choose from. Default: upper, lower, numbers, and underscore.
|
||||
-- @return The random string.
|
||||
get_random_string = function(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
|
||||
end
|
||||
return stdnse.generate_random_string(length or 8,
|
||||
set or "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_")
|
||||
end,
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user