summaryrefslogtreecommitdiffhomepage
path: root/libs/core/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/core/luasrc')
-rw-r--r--libs/core/luasrc/sys.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua
index 17caa78241..54c4e06137 100644
--- a/libs/core/luasrc/sys.lua
+++ b/libs/core/luasrc/sys.lua
@@ -134,6 +134,23 @@ function syslog()
end
+-- Generates a random key of length BYTES
+function uniqueid(bytes)
+ local fp = io.open("/dev/urandom")
+ local chunk = { fp:read(bytes):byte(1, bytes) }
+ fp:close()
+
+ local hex = ""
+
+ local pattern = "%02X"
+ for i, byte in ipairs(chunk) do
+ hex = hex .. pattern:format(byte)
+ end
+
+ return hex
+end
+
+
group = {}
group.getgroup = posix.getgroup