mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 00:33:44 +01:00
Add text.random_bytes
This commit is contained in:
parent
53bb6915db
commit
88aca204f3
14
text.lua
14
text.lua
@ -145,5 +145,19 @@ function ibytes(text, start)
|
||||
return inextbyte, text, (start or 1) - 1
|
||||
end
|
||||
|
||||
local function _random_bytes(count)
|
||||
if count == 0 then return end
|
||||
return math.random(0, 0xFF), _random_bytes(count - 1)
|
||||
end
|
||||
|
||||
function random_bytes(
|
||||
-- number, how many random bytes the string should have, defaults to 1
|
||||
-- limited by stack size
|
||||
count
|
||||
)
|
||||
count = count or 1
|
||||
return string.char(_random_bytes(count))
|
||||
end
|
||||
|
||||
-- Export environment
|
||||
return _ENV
|
||||
|
Loading…
Reference in New Issue
Block a user