Jump to content
Welcome to our new Citrix community!

random-uuid all 0's

Recommended Posts



I have been asked to look at our netscaler to see if there is an issue with our ADC not successfully creating a random UUID.

Rather than returning random characters it is just returning 0's.  random-uuid6.lua is the name of the source (think that can be whatever we want)

I have been told that Math.randomseed is the issue here. I have upgraded the ADC from 12.1 to 13.0 to see if that resolved the issue, it didnt.


below is the code that we have in Policy Entension contents



math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )

    local myNum = math.floor((math.random() * 10000000000000) % 16)

    local myNum2 = math.random(1.0, 16.0)

local luaVersion=_VERSION


    local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'

    local uuid = string.gsub(template, '[xy]', function (c)

        local v = 0

        local v = (c == 'x') and math.random(0, 16) or math.random(8, 0xb)

        return string.format('%x', v)




    return tostring(uuid)



I have been told tha tthis is not passing back a whole number, just a fraction, this could be why this is setting it as 0's

Not too sure whether there is an issue with math.randomseed on the ADC's (no general known issue that I can find) or it is just the code is not quite right.


Sorry for being so vague.




Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...