$uuid

Generate a globally unique identifier.

$uuid

Example: PK=$uuid

Return Values

A UUID (Universally Unique IDentifier) in the format of 8-4-4-4-12 hexadecimal characters.

Use

Allowed in all component types.

Description

$uuid can be useful for generating technical keys, session IDs, random file names, or any other situation in which a unique identifier is required.

The UUID is a 16-byte number that is represented as a 32 character hexadecimal string, such as {21EC2020-3AEA-1069-A2DD-08002B30309D}. It is made up of components that represent the time, a version, and an Ethernet address, although the actual Ethernet address is not necessarily used.

UUID Generation on Windows

On Microsoft Windows platforms, where a UUID is usually called a GUID (Globally Unique IDentifier), the RPC function UuidCreate() is used. This function generates a UUID that cannot be traced to the ethernet address of the computer on which it was generated.

UUID Generation on Non-Windows Platforms

On non-Windows platforms, the generated UUID is based on an OSF Internet-Draft (www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt).

Instead of an actual Ethernet address, Uniface generates a random number based on the current time in milliseconds and the process ID. A bit in the UUID is set to indicate that the number is generated, thus ensuring that the random number cannot clash with an existing Ethernet address.

The number is generated only once per process, so the last part of all generated UUIDs in one Uniface process are all the same. There cannot be two processes with the same PID at the same time on the same machine, so two Uniface processes running on one machine will never generate the same number.

It is theoretically possible that the generated UUID is not unique, but the chances are negligible. This would require two Uniface processes running on two different machines to have the same PID, and they would need to generate their UUIDs at exactly the same time to millisecond precision.

Generating Session IDs

A session ID is used in disconnected environments where the client is stateful, the server is stateless, and the server needs to know which client session it is serving.

Using a UUID on its own does not provide sufficient uniqueness or randomness for web communications, so you can construct one, for example using a UUID encoded with a random key.

variables
  string vSessionId, vRandomKey
endvariables


vRandomKey = "GsbnFhyaPF11jIWyFaCu9zogqJALG50NDGXL0clX1"
vSessionId=$encode("HEX",$encode("HMAC_MD5", $uuid, vRandomKey))

Related Topics