Get UUID on *NIX

Difference between version 1 and 2 - Previous - Next
Created by [CecilWesterhof].
'''**Getting an UUID on a *NIX System'''**
There are some problems with getting the UUID (type 4) on *NIX systems. For one they are not really random.
There are some problems with getting the [UUID] (type 4) on *NIX systems. For one they are not really random.

Because of this I created the following function:
======
proc getUUIDNix {{secure False}} {
    set fortyeightBits [expr {2 ** 48 - 1}]
    set sixteenBits    [expr {2 ** 16 - 1}]
    set thirtytwoBits  [expr {2 ** 32 - 1}]
    set twelfBits      [expr {2 ** 12 - 1}]

    format %.8x-%.4x-4%.3x-%x%.3x-%.12x \
        [getRandomIntInRangeNix 0 ${thirtytwoBits}] \
        [getRandomIntInRangeNix 0 ${sixteenBits}]   \
        [getRandomIntInRangeNix 0 ${twelfBits}]     \
        [getRandomIntInRangeNix 8 11]               \
        [getRandomIntInRangeNix 0 ${twelfBits}]     \
        [getRandomIntInRangeNix 0 ${fortyeightBits} False True]
}
======

It uses getRandomIntInRangeNix from [Random Integers].

----

As always: comments, tips and questions are appreciated.
----
'''[ak]** -See 2018-05-31also 18:28:08'''**
See also https://c * [UUID] fore.tcl.tk/tcllib/d oc/therunk/ implembedded/www/ntcllatib/files/modulens/uuid/uuid.html
** Discussion **

<<categories>>Linux | Utilities