在lua中正确使用uuid的方法:
2015-05-07 20:54
302 查看
-- 参考:http://ju.outofmemory.cn/entry/97724 local function guid() local template ="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" local d = io.open("/dev/urandom", "r"):read(4) math.randomseed(os.time() + d:byte(1) + (d:byte(2) * 256) + (d:byte(3) * 65536) + (d:byte(4) * 4294967296)) return string.upper(string.gsub(template, "x", function (c) local v = (c == "x") and math.random(0, 0xf) or math.random(8, 0xb) return string.format("%x", v) end )) end local file_id = guid();
相关文章推荐
- PS2正确使用方法
- 重要知识:身份证复印件的正确使用方法
- 身份证复印件的正确使用方法
- 身份证复印件的正确使用方法
- 将图片插入数据库并使用asp.net读取出来的正确方法
- 如何正确的使用Timer的schedule()方法?
- 使用namespace的正确方法
- Atlas M3: ErrorTemplate正确使用方法
- Atlas M3: ErrorTemplate正确使用方法
- 将图片插入数据库并使用asp.net读取出来的正确方法
- 重要知识:身份证复印件的正确使用方法
- [转]重要知识:身份证复印件的正确使用方法
- 单击以激活并使用此控件正确解决方法
- 祛除光盘上的小划痕/光盘的工作原理/光盘的正确使用方法
- 电烙铁的正确使用方法
- log的正确使用方法
- JProfiler在Linux下的正确使用方法
- 【重要知识】身份证复印件的正确使用方法
- 如何正确使用List中的toArray()方法
- 在用户控件中使用 MapControl 的正确方法 mapxtreme载入地图