QUuid change variant
-
wrote on 14 Oct 2023, 01:33 last edited by
Hi!
I saw in documentation for QUuid have variants. but I didn't get how to generate it.
if I generate by var = QUuid::createUuid();
var.variant() - shows '2'
but how to change it? how to generate uuid with variant 4?
thanks in advance -
Hi!
I saw in documentation for QUuid have variants. but I didn't get how to generate it.
if I generate by var = QUuid::createUuid();
var.variant() - shows '2'
but how to change it? how to generate uuid with variant 4?
thanks in advancewrote on 14 Oct 2023, 03:22 last edited by@MadBee I think you are confusing the UUID variant (DCE, the variant described in RFC 4122) with the UUID version (a sub-type of variant):
The following table lists the currently-defined versions for this UUID variant. Msb0 Msb1 Msb2 Msb3 Version Description 0 0 0 1 1 The time-based version specified in this document. 0 0 1 0 2 DCE Security version, with embedded POSIX UIDs. 0 0 1 1 3 The name-based version specified in this document that uses MD5 hashing. 0 1 0 0 4 The randomly or pseudo- randomly generated version specified in this document. 0 1 0 1 5 The name-based version specified in this document that uses SHA-1 hashing.
You get a version 4 (random) UUID by default QUuid::createUuid() but there are similar functions to create version 3 and 5 UUIDs. You can construct a QUuid object specifying all the components yourself to obtain a UUID of any variant or version.
1/2