How is a Random UUID / GUID made

This is the easiest UUID to generate, (at least when you have a good random generator). No guarantees can be made towards uniqueness though.
Here is a simple recipy:
Take 16 random bytes (octets), put them all behind each other, for the description the numbering starts with byte 1 (most significant, first) to byte 16 (least significant, last). Then put in the version and variant.
To put in the version, take the 7th byte and perform an and operation using 0x0f, followed by an or operation with 0x40.
To put in the variant, take the  9th byte and perform an and operation using  0x3f, followed by an or operation with 0x80.
To make the string representation, take the hexadecimal presentation of bytes 1-4  (without 0x in front of it) let them follow by a -, then take bytes 5 and 6, - bytes 7 and 8, - bytes 9 and 10, - then followed by bytes 11-16.
The result is something like:
00e8da9b-9ae8-4bdd-af76-af89bed2262f
The bold 4 and the bold a are the positions where the version and the variant are introduced. Instead of the a, also an 8, 9 or b could be present on that position.

Note: the correct way to construct these identifiers is described in RFC 4122 the contents of this document is my interpretation of that document.

How is an UUID made (with information about version and variant)

I need an version 4 UUID

If you have improvements, contact information on the homepage of this host.
An agent adding logging to your java programs at runtime
The uptime of home.famkruithof.net