Converts a string GUID to a hexdecimal value so it can be queried.

@param string $strGUID A string representation of a GUID

@return string
763225
public function strGuidToHex($strGUID)
    {
        $strGUID = str_replace('-', '', $strGUID);

        $octet_str = '\\'.substr($strGUID, 6, 2);
        $octet_str .= '\\'.substr($strGUID, 4, 2);
        $octet_str .= '\\'.substr($strGUID, 2, 2);
        $octet_str .= '\\'.substr($strGUID, 0, 2);
        $octet_str .= '\\'.substr($strGUID, 10, 2);
        $octet_str .= '\\'.substr($strGUID, 8, 2);
        $octet_str .= '\\'.substr($strGUID, 14, 2);
        $octet_str .= '\\'.substr($strGUID, 12, 2);

        $length = (strlen($strGUID) - 2);

        for ($i = 16; $i <= $length; $i++) {
            if (($i % 2) == 0) {
                $octet_str .= '\\'.substr($strGUID, $i, 2);
            }
        }

        return $octet_str;
    }
824089
private function hex2rgb($hex)
    {
        $hex = str_replace('#', '', $hex);

        // expand shorthand notation (#36A -> #3366AA)
        if (3 == strlen($hex)) {
            $hex = $hex{0}
            .$hex{0}
            .$hex{1}
            .$hex{1}
            .$hex{2}
            .$hex{2};
        }

        return array(
            hexdec(substr($hex, 0, 2)),
            hexdec(substr($hex, 2, 2)),
            hexdec(substr($hex, 4, 2)),
        );
    }
941930
private function _str2hex($string)
    {
        $hex = bin2hex($string);
        $xhex = "";

        for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
            $xhex .= '\x' . $hex[$i] . $hex[$i + 1];
        }

        return $xhex;
    }
732443
public static function uuid(string $prefix = ''): string {
		$chars = md5(uniqid($prefix, true));
		$uuid  = '';
		for ($i = 0; $i < 36; $i++)
			$uuid .= ($i === 8 || $i === 15 || $i === 20 || $i === 25) ? '-' : $chars[mt_rand(0, 31)];
		return $uuid;
	}
381009
public static function convert(string $uuid)
    {
        // convert to 16 byte binary representation
        $bin = hex2bin(str_replace(['{', '-', '}'], '', $uuid));

        // xor first half with second to give 8 bytes
        $xor = self::xor(...str_split($bin, 8));

        // convert to a 64-bit signed integer
        return unpack('q', $xor)[1];
    }
219496
public function decodeType(string $globalID): string
    {
        [$type, $id] = self::decode($globalID);

        return $type;
    }
1301130
public function encode(UuidInterface $uuid)
    {
        $sixPieceComponents = array_values($uuid->getFieldsHex());

        $this->swapTimestampAndRandomBits($sixPieceComponents);

        return vsprintf(
            '%08s-%04s-%04s-%02s%02s-%012s',
            $sixPieceComponents
        );
    }
1365498
public static function bancontact($UUID, $withBase64 = false)
    {
        $qrUrl = 'https://chart.googleapis.com/chart?cht=qr&chs=260x260&chl=https://qr.pisp.me/bc/' . $UUID;
        $result = [
            'url' => 'https://qr.pisp.me/bc/' . $UUID,
            'QRUrl' => $qrUrl
        ];
        if($withBase64) $result['QRBase64'] = base64_encode(file_get_contents($qrUrl));

        return $result;
    }
1200282
private function generateUUID()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }
1354123
public function pgettext($msgctxt, $msgid)
    {
        $key = implode(chr(4), [$msgctxt, $msgid]);
        $ret = $this->gettext($key);
        if (strpos($ret, chr(4)) !== false) {
            return $msgid;
        }

        return $ret;
    }
544404
public static function uid10(): string
    {
        $converted = base_convert(self::$hex_chars[random_int(0, 15)] . uniqid('', true) . self::$hex_chars[random_int(0, 15)], 16, 10);
        $res = '';

        for ($i = floor(log10((float)$converted) / 1.7923916894983); $i >= 0; --$i) {
            // Random index
            $j = 62 ** $i;
            $a = (int)floor($converted / $j);
            $res .= self::$alphanum_chars[$a];

            $converted -= $a * $j;
        }

        return sprintf('%010s', $res);
    }
661660
public static function toHexadecimal(string $bytes): string
	{
		if(strlen($bytes) !== 16)
		{
			throw new InvalidArgumentException('The input must be exactly 16 bytes.');
		}

		return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($bytes), 4));
	}
256726
public static function convert_uids($st){
    if ( \is_array($st) || \is_object($st) ){
      foreach ( $st as &$s ){
        $s = self::convert_uids($s);
      }
    }
    else if ( \bbn\str::is_uid($st) ){
      $st = bin2hex($st);
    }
    return $st;
  }
602097
public static function GUid(): string
    {
        mt_srand((double)microtime() * 10000);

        $charId = strtolower(md5(uniqid(mt_rand(), true)));
        // $hyphen = chr(45);
        $uuid = substr($charId, 0, 8) .
            substr($charId, 8, 4) .
            substr($charId, 12, 4) .
            substr($charId, 16, 4) .
            substr($charId, 20, 12);

        return $uuid;
    }
574770
public static function NewGuid()
    {
        if (function_exists('com_create_guid')) {
            return trim(com_create_guid(), "{}");
        } else {
            $charid = strtoupper(bin2hex(openssl_random_pseudo_bytes(16)));
            $hyphen = chr(45);
            $uuid = substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12);
            return $uuid;
        }
    }
627026
public function hex2bin($hexString)
    {
        $pos = 0;
        $result = '';
        while ($pos < strlen($hexString)) {
            if (strpos(" \t\n\r", $hexString[$pos]) !== false) {
                ++$pos;
            } else {
                $code = hexdec(substr($hexString, $pos, 2));
                $pos += 2;
                $result .= chr($code);
            }
        }

        return $result;
    }
353162
public function reduce(string $uuid): string
    {
        $dictionaryLength = $this->dictionary->getLength();
        $uuidInt = $this->converter->fromHex($uuid);
        $output = '';

        while ($uuidInt->getValue() > 0) {
            $previousNumber = clone $uuidInt;
            $uuidInt = $uuidInt->divide($dictionaryLength);
            $digit = $previousNumber->mod($dictionaryLength);
            $output .= $this->dictionary->getCharAt((int) $digit->getValue());
        }

        return $output;
    }