![]() uuid-ossp can now be built without the OSSP library on some platforms. While the OSSP UUID library can still be found at, it is not well maintained, and is becoming increasingly difficult to port to newer platforms. Historically this module depended on the OSSP UUID library, which accounts for the module's name. Version 5 should be preferred over version 3 because SHA-1 is thought to be more secure than MD5. Generates a version 5 UUID, which works like a version 3 UUID except that SHA-1 is used as a hashing method. Uuid_generate_v5 ( namespace uuid, name text ) → uuid Generates a version 4 UUID, which is derived entirely from random numbers. The generation of UUIDs by this method has no random or environment-dependent element and is therefore reproducible. The name parameter will be MD5-hashed, so the cleartext cannot be derived from the generated UUID. SELECT uuid_generate_v3(uuid_ns_url(), '') ![]() (It could be any UUID in theory.) The name is an identifier in the selected namespace. The namespace should be one of the special constants produced by the uuid_ns_*() functions shown in Table F.35. Generates a version 3 UUID in the given namespace using the specified input name. Uuid_generate_v3 ( namespace uuid, name text ) → uuid Generates a version 1 UUID, but uses a random multicast MAC address instead of the real MAC address of the computer. Note that UUIDs of this kind reveal the identity of the computer that created the identifier and the time at which it did so, which might make it unsuitable for certain security-sensitive applications. This involves the MAC address of the computer and a time stamp. $uuid1 ->equals( $uuid4) // false // this method returns: // * int(0) if $uuid1 and $uuid4 are equal // * int > 0 if $uuid1 is greater than $uuid4 // * int compare( $uuid4) // e.g.Generates a version 1 UUID. $uuid ->getDateTime() // returns a \DateTimeImmutable instance // checking if a given value is valid as UUID $isValid = Uuid ::isValid( $uuid) // true or false // comparing UUIDs and checking for equality $uuid1 = Uuid ::v1() $uuid instanceof UuidV4 // true // getting the UUID datetime (it's only available in certain UUID types) $uuid = Uuid ::v1() $uuid instanceof NilUuid // false // checking the type of UUID use Symfony\ Component\ Uid\ UuidV4 checking if the UUID is null (note that the class is called // NilUuid instead of NullUuid to follow the UUID standard notation) $uuid = Uuid ::v4() If your UUID value is already generated in another format, use any of theįollowing methods to create a Uuid object from it: The only requirement is that the variant and version bits MUST be set as defined in Section 4: // // UUIDv8 uniqueness will be implementation-specific and SHOULD NOT be assumed. UUID version 8 provides an RFC-compatible format for experimental or vendor-specific use cases. As well as improved entropy characteristics over versions 1 or 6. It's defined in $uuid = Uuid ::v6() // $uuid is an instance of Symfony\Component\Uid\UuidV6 // UUID version 7 features a time-ordered value field derived from the well known // Unix Epoch timestamp source: the number of seconds since midnight UTC, leap seconds excluded. It's lexicographically sortable // (like ULIDs) and contains a 60-bit timestamp and 63 extra unique bits. $uuid = Uuid ::v3( $namespace, $name) // $uuid is an instance of Symfony\Component\Uid\UuidV3 $uuid = Uuid ::v5( $namespace, $name) // $uuid is an instance of Symfony\Component\Uid\UuidV5 // the namespaces defined by RFC 4122 (see ) // are available as PHP constants and as string values $uuid = Uuid ::v3(Uuid ::NAMESPACE_DNS, $name) // same as: Uuid::v3('dns', $name) $uuid = Uuid ::v3(Uuid ::NAMESPACE_URL, $name) // same as: Uuid::v3('url', $name) $uuid = Uuid ::v3(Uuid ::NAMESPACE_OID, $name) // same as: Uuid::v3('oid', $name) $uuid = Uuid ::v3(Uuid ::NAMESPACE_X500, $name) // same as: Uuid::v3('x500', $name) // UUID type 6 is not yet part of the UUID standard. a Type 4 UUID) // and the name is an arbitrary string (e.g. Type 3 uses // MD5 hashes and Type 5 uses SHA-1. $uuid = Uuid ::v4() // $uuid is an instance of Symfony\Component\Uid\UuidV4 // UUID type 3 and 5 generate a UUID hashing the given namespace and name. $uuid = Uuid ::v1() // $uuid is an instance of Symfony\Component\Uid\UuidV1 // UUID type 4 generates a random UUID, so you don't have to pass any constructor argument. Both are obtained automatically, so you don't have to pass any constructor argument. UUID type 1 generates the UUID using the MAC address of your device and a timestamp.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |