Module uuid

Copyright 2012 Rackspace (original), 2013-2024 Thijs Schreijer (modifications)

see http://www.ietf.org/rfc/rfc4122.txt and https://www.ietf.org/rfc/rfc9562.txt

Info:

Functions

set_rng (func[, err]) Sets the function to be used to generate random bytes.
v4 () Creates a new v4 uuid.


Functions

set_rng (func[, err])
Sets the function to be used to generate random bytes. The signature of the function should be func(n), where n is the number of bytes to generate. The function should return a binary string of random bytes (not hex or otherwise encoded). Upon error it should return nil + error message.

The second parameter is used to directly pass in errors from the rng functions. See the example.

Parameters:

  • func function the function to be used to generate random bytes
  • err string optional error message to be thrown when func is not a function (optional)

Returns:

    boolean true

Usage:

    -- set the random number generator for /dev/urandom. On Windows this isn't available
    -- and it returns nil+error, which is passed on to set_rng which then
    -- throws a meaningful error.
    uuid.set_rng(uuid.rng.urandom())
v4 ()
Creates a new v4 uuid. Calling on the module table is a shortcut for this function.

Returns:

    string a properly formatted uuid string
generated by LDoc 1.5.0 Last updated 2024-10-13 00:59:03