1
0
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:
dmiller
2015-02-25 05:06:08 +00:00
parent f6733b2d89
commit db717c7543
10 changed files with 15 additions and 119 deletions

View File

@@ -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,
}