【发布时间】:2022-09-23 02:19:28
【问题描述】:
local function generator()
local capital_letters = {\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\", \"K\", \"L\", \"M\", \"N\", \"O\", \"P\", \"Q\", \"R\", \"S\", \"T\", \"U\", \"V\", \"W\", \"X\", \"Y\", \"Z\"}
local low_letters = {\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"}
local numbers = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
local Random_capital_letters = math.random(26)
local Random_low_letters = math.random(26)
local Random_numbers = math.random(10)
local length = 10
print(\"this is your generatet password: \"..Random_capital_letters, Random_low_letters, Random_numbers[length])
math.randomseed(os.time())
end
generator()
它只是一直给我一个错误,如果有人可以帮助我,那就太酷了!
-
您正在...索引一个您应该用作索引的数字???应该是
capital_letters[math.random(#capital_letters)]等。 -
当您遇到错误时,您应该始终将其包含在您的帖子中,这样我们就更容易“教你如何钓鱼”
-
我没有看到构造字符串的实际循环。您需要循环
x次(所需字符串的长度)并在每次循环中选择一个随机字符,然后将其附加到最终字符串。 -
另请注意,
math.randomseed(os.time())应在使用之前调用,math.random方法 - 否则它们是非常可预测的。在同一张纸条上使用os.time()可能如果调用速度足够快,则会产生相同的输出。
标签: random lua passwords generator