• 在lua中正确使用uuid的方法:


    -- 参考: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();
  • 相关阅读:
    怎么说???
    再给自己一点鼓励
    还是不要看新闻的好
    系统架构师
    朋友
    未来的路
    I now have a dream
    纪念死去的手机
    全局规划
    终于要上战场了!
  • 原文地址:https://www.cnblogs.com/littlehb/p/4486019.html
Copyright © 2020-2023  润新知