public static function generateMongoId ($iTimestamp = 0, $bBase32 = true)
    {
        static $inc = 0;
        if ($inc === 0) {
            // set with microseconds:
            $inc = (int)substr(microtime(), 2, 6);
        }

        $bin = sprintf(
            '%s%s%s%s',
            pack('N', $iTimestamp ?: time()),
            substr(md5(gethostname()), 0, 3),
            pack('n', posix_getpid()),
            substr(pack('N', $inc++), 1, 3)
        );

        return $bBase32 ? strtolower(Base32::encodeByteStr($bin, true)) : bin2hex($bin);
    }