Documentation Clarification
lordnynex opened this issue · 0 comments
lordnynex commented
The example documentation for resty.random.bytes() contains a while loop. Is there a situation where resty.random.bytes() can return nil, or is this an error in the documentation?
local resty_random = require "resty.random"
local str = require "resty.string"
local strong_random = resty_random.bytes(16,true)
-- attempt to generate 16 bytes of
-- cryptographically strong random data
while strong_random == nil do
strong_random = resty_random.bytes(16,true)
end
ngx.say("random: ", str.to_hex(strong_random))