/usr/share/lua/5.1/nginx/random.lua is in lua-nginx-string 0.09-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | -- Copyright (C) by Yichun Zhang (agentzh)
local ffi = require "ffi"
local ffi_new = ffi.new
local ffi_str = ffi.string
local C = ffi.C
local setmetatable = setmetatable
local error = error
local _M = { _VERSION = '0.09' }
ffi.cdef[[
int RAND_bytes(unsigned char *buf, int num);
int RAND_pseudo_bytes(unsigned char *buf, int num);
]]
function _M.bytes(len, strong)
local buf = ffi_new("char[?]", len)
if strong then
if C.RAND_bytes(buf, len) == 0 then
return nil
end
else
C.RAND_pseudo_bytes(buf,len)
end
return ffi_str(buf, len)
end
return _M
|