/*
Generate UUID version 3 and 5 (name based)
766125
static private function generateName($ns, $node, $hash, $version) {
    $ns_fmt = self::detectFormat($ns);
    $field = self::convert($ns, $ns_fmt, self::FMT_FIELD);

    /* Swap byte order to keep it in big endian on all platforms */
    $field['time_low'] = self::swap32($field['time_low']);
    $field['time_mid'] = self::swap16($field['time_mid']);
    $field['time_hi'] = self::swap16($field['time_hi']);

    /* Convert the namespace to binary and concatenate node */
    $raw = self::convert($field, self::FMT_FIELD, self::FMT_BINARY);
    $raw .= $node;

    /* Hash the namespace and node and convert to a byte array */
    $val = $hash($raw, true);
    $tmp = unpack('C16', $val);
    foreach (array_keys($tmp) as $key)
      $byte[$key - 1] = $tmp[$key];

    /* Convert byte array to a field array */
    $field = self::conv_byte2field($byte);

    $field['time_low'] = self::swap32($field['time_low']);
    $field['time_mid'] = self::swap16($field['time_mid']);
    $field['time_hi'] = self::swap16($field['time_hi']);

    /* Apply version and constants */
    $field['clock_seq_hi'] &= 0x3f;
    $field['clock_seq_hi'] |= (1 << 7);
    $field['time_hi'] &= 0x0fff;
    $field['time_hi'] |= ($version << 12);

    return ($field);
  }
814642
def uuid5(namespace, name):
    """"""
    import sha
    hash = sha.sha(namespace.bytes + name).digest()
    return UUID(bytes=hash[:16], version=5)
231279
private void generateUUIDs(CmsSetupDb dbCon) throws SQLException {

        System.out.println(new Exception().getStackTrace()[0].toString());
        String query = readQuery(QUERY_GET_PROJECT_IDS);

        CmsSetupDBWrapper db = null;
        try {
            db = dbCon.executeSqlStatement(query, null);
            ResultSetMetaData metaData = db.getResultSet().getMetaData();
            // Check the type of the column if it is integer, then create the new uuids
            int columnType = metaData.getColumnType(1);
            if (checkColumnTypeProjectId(columnType)) {
                if (!dbCon.hasTableOrColumn(TEMPORARY_TABLE_NAME, null)) {
                    createTempTable(dbCon);

                    String updateQuery = readQuery(QUERY_INSERT_UUIDS);
                    List<Object> params = new ArrayList<Object>();
                    // Get the project id and insert it with a new uuid into the temp table
                    boolean hasNullId = false;
                    while (db.getResultSet().next()) {
                        int id = db.getResultSet().getInt("PROJECT_ID");
                        params.add(new Integer(id)); // Add the number
                        CmsUUID uuid = new CmsUUID();

                        // Check for 0 project id
                        if (id == 0) {
                            hasNullId = true;
                            uuid = CmsUUID.getNullUUID();
                        }
                        // Check for the online project
                        if (id == 1) {
                            uuid = CmsProject.ONLINE_PROJECT_ID;
                        }
                        params.add(uuid.toString()); // Add the uuid

                        // Insert the values to the temp table
                        dbCon.updateSqlStatement(updateQuery, null, params);

                        params.clear();
                    }

                    // If no project id with value 0 was found
                    if (!hasNullId) {
                        params.add(new Integer(0));
                        params.add(CmsUUID.getNullUUID().toString());
                        dbCon.updateSqlStatement(updateQuery, null, params);
                    }
                } else {
                    System.out.println("table " + TEMPORARY_TABLE_NAME + " already exists");
                }
            }
        } finally {
            if (db != null) {
                db.close();
            }
        }
    }
496182
final public static function generateUidie():string
    {
        // i for iumio
        $str = "i";
        // Create a string with Alphabetic letter
        $str .= chr(rand(65, 90));
        // Insert the timestamp
        $str .= time();
        // Create an other unique identifier with lenght 5
        $uniqid = substr(uniqid("X"), 5);
        // concat all
        $str .= substr($uniqid, 5);

        return ($str);
    }
40010
public static Identifier fromUuid(UUID uuid) {
        ByteBuffer buf = ByteBuffer.allocate(16);
        buf.putLong(uuid.getMostSignificantBits());
        buf.putLong(uuid.getLeastSignificantBits());
        return new Identifier(buf.array());
    }
434032
public static function createUuid() {
		$data = \openssl_random_pseudo_bytes(16);

		// set the version to 0100
		$data[6] = \chr(\ord($data[6]) & 0x0f | 0x40);
		// set bits 6-7 to 10
		$data[8] = \chr(\ord($data[8]) & 0x3f | 0x80);

		return \vsprintf('%s%s-%s-%s-%s-%s%s%s', \str_split(\bin2hex($data), 4));
	}
177814
public static UUID nameUUIDFromBytes(byte[] name) {
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("MD5");
		} catch (NoSuchAlgorithmException nsae) {
			throw new InternalError("MD5 not supported");
		}
		byte[] md5Bytes = md.digest(name);
		md5Bytes[6] &= 0x0f; /* clear version */
		md5Bytes[6] |= 0x30; /* set to version 3 */
		md5Bytes[8] &= 0x3f; /* clear variant */
		md5Bytes[8] |= 0x80; /* set to IETF variant */
		return new UUID(md5Bytes);
	}
753039
public function generateUuid()
    {
        $serialized = serialize($this->envInformations);
        $this->uuid = dechex($this->getDate()->format('Ymd')) . substr(sha1(implode([
            microtime(),
            $serialized,
            $this->configPath,
        ])), 0, -7);
    }
72108
protected function generateIdentifier()
	{
		// If the mongo extension is loaded, utilize it to generate a UUID.
		if(extension_loaded('mongodb'))
		{
			$newObjectId = new \MongoDB\BSON\ObjectID();

			$uuid = $newObjectId->__toString();
		}
		else
		{
			$uuid = bin2hex(openssl_random_pseudo_bytes(12));
		}

		return $uuid;
	}
1035933
private static CmsUUID toUuid(String uuid) {

        if ("null".equals(uuid) || CmsStringUtil.isEmpty(uuid)) {
            return null;
        }
        return new CmsUUID(uuid);

    }
147443
public void sortedUUIDGenerator(String name, Integer sortedLength, Integer uuidLength) {
		checkReadOnly();
		DialectException.assureNotNull(name);
		if (this.getIdGenerator(GenerationType.SORTED_UUID, name) != null)
			throw new DialectException("Duplicated sortedUUIDGenerator name '" + name + "'");
		idGenerators.add(new SortedUUIDGenerator(name, sortedLength, uuidLength));
	}
976412
@Nonnull
  public FineUploader5Request setUUIDName (@Nonnull @Nonempty final String sUUIDName)
  {
    ValueEnforcer.notEmpty (sUUIDName, "UUIDName");
    m_sRequestUUIDName = sUUIDName;
    return this;
  }
1331504
function _generateUUID() {
        var result,
            numericSeed;
        for (
            result = numericSeed = '';
            numericSeed++ < 36;
            result += numericSeed * 51 & 52 ? (numericSeed ^ 15 ? 8 ^ Math.random() * (numericSeed ^ 20 ? 16 : 4) : 4).toString(16) : '-'
        );

        return result;
    }
1220209
public static final void uuid(String uuid)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "uuid", uuid);

        _uuid = uuid;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "uuid");
    }
1042817
public static String uuidToEntityId(CmsUUID uuid, String locale) {

        return ENTITY_ID_PREFIX + locale + "/" + uuid.toString();
    }
657917
function uuid() {
  return crypto.randomBytes(4).toString('hex') + '-' +
    crypto.randomBytes(2).toString('hex') + '-' +
    crypto.randomBytes(2).toString('hex').replace(/^./, '1') + '-' +
    crypto.randomBytes(2).toString('hex') + '-' +
    crypto.randomBytes(6).toString('hex')
}
1354930
def post_generate_identifier(request):
    """"""
    d1_gmn.app.views.assert_db.post_has_mime_parts(request, (('field', 'scheme'),))
    if request.POST['scheme'] != 'UUID':
        raise d1_common.types.exceptions.InvalidRequest(
            0, 'Only the UUID scheme is currently supported'
        )
    fragment = request.POST.get('fragment', None)
    while True:
        pid = (fragment if fragment else '') + uuid.uuid4().hex
        if not d1_gmn.app.models.ScienceObject.objects.filter(pid__did=pid).exists():
            return pid