Generate a 64bit base 16 ID for use as a Span or Trace ID
328954
def generate_id():
    
    global _current_pid

    pid = os.getpid()
    if _current_pid != pid:
        _current_pid = pid
        _rnd.seed(int(1000000 * time.time()) ^ pid)
    id = format(_rnd.randint(0, 18446744073709551615), '02x')

    if len(id) < 16:
        id = id.zfill(16)

    return id
1081046
private static long SBOG_LPSti64(byte[] t, int i) {
        return (StreebogTables.sbob_sl64[0][t[i] & 0xFF] ^
                StreebogTables.sbob_sl64[1][t[i + 8] & 0xFF] ^
                StreebogTables.sbob_sl64[2][t[i + 16] & 0xFF] ^
                StreebogTables.sbob_sl64[3][t[i + 24] & 0xFF] ^
                StreebogTables.sbob_sl64[4][t[i + 32] & 0xFF] ^
                StreebogTables.sbob_sl64[5][t[i + 40] & 0xFF] ^
                StreebogTables.sbob_sl64[6][t[i + 48] & 0xFF] ^
                StreebogTables.sbob_sl64[7][t[i + 56] & 0xFF]);
    }
1303269
def extern_store_i64(self, context_handle, i64):
    """"""
    c = self._ffi.from_handle(context_handle)
    return c.to_value(i64)
575257
private long createTraceIdHigh() {
    long epochSeconds = System.currentTimeMillis() / 1000;
    int random = this.random.nextInt();
    return (epochSeconds & 0xffffffffL) << 32 | (random & 0xffffffffL);
  }
1054289
function ScriptNum(num, base) {
  if (!(this instanceof ScriptNum))
    return new ScriptNum(num, base);

  I64.call(this, num, base);
}
504297
def _raw_hex_id(obj):
    """"""
    # interpret as a pointer since that's what really what id returns
    packed = struct.pack('@P', id(obj))
    return ''.join(map(_replacer, packed))
100115
def _uint2objs(ftype, num, length=None):
    """"""
    if num == 0:
        objs = [ftype.box(0)]
    else:
        _num = num
        objs = list()
        while _num != 0:
            objs.append(ftype.box(_num & 1))
            _num >>= 1

    if length:
        if length < len(objs):
            fstr = "overflow: num = {} requires length >= {}, got length = {}"
            raise ValueError(fstr.format(num, len(objs), length))
        else:
            while len(objs) < length:
                objs.append(ftype.box(0))

    return objs
1330602
private String generateSilientCheckpointId() {
        byte[] randomBytes = new byte[32];
        ThreadLocalRandom.current().nextBytes(randomBytes);
        return Base64.getEncoder().encodeToString(randomBytes) + SILENT;
    }
822646
synchronized public long generateId48() {
        final long blockSize = 1000L; // block 1000 ms
        long timestamp = System.currentTimeMillis() / blockSize;
        long sequence = 0;
        boolean done = false;
        while (!done) {
            done = true;
            while (timestamp < lastTimestampMillisec.get() / blockSize) {
                timestamp = waitTillNextSecond(timestamp);
            }
            if (timestamp == lastTimestampMillisec.get() / blockSize) {
                // increase sequence
                sequence = sequenceMillisec.incrementAndGet();
                if (sequence > MAX_SEQUENCE_48) {
                    // reset sequence
                    sequenceMillisec.set(sequence = 0);
                    timestamp = waitTillNextSecond(timestamp);
                    done = false;
                }
            }
        }
        sequenceMillisec.set(sequence);
        lastTimestampMillisec.set(timestamp * blockSize);
        timestamp = ((timestamp * blockSize - TIMESTAMP_EPOCH) / blockSize) & MASK_TIMESTAMP_48;
        return timestamp << SHIFT_TIMESTAMP_48 | template48 | (sequence & MASK_SEQUENCE_48);
    }
942880
def _encode_uuid(name, value, dummy, opts):
    """"""
    uuid_representation = opts.uuid_representation
    # Python Legacy Common Case
    if uuid_representation == OLD_UUID_SUBTYPE:
        return b"\x05" + name + b'\x10\x00\x00\x00\x03' + value.bytes
    # Java Legacy
    elif uuid_representation == JAVA_LEGACY:
        from_uuid = value.bytes
        data = from_uuid[0:8][::-1] + from_uuid[8:16][::-1]
        return b"\x05" + name + b'\x10\x00\x00\x00\x03' + data
    # C# legacy
    elif uuid_representation == CSHARP_LEGACY:
        # Microsoft GUID representation.
        return b"\x05" + name + b'\x10\x00\x00\x00\x03' + value.bytes_le
    # New
    else:
        return b"\x05" + name + b'\x10\x00\x00\x00\x04' + value.bytes
1279339
function generateGuid() {
    var buf = new Uint16Array(8);
    buf = crypto.randomBytes(8);
    var S4 = function(num) {
            var ret = num.toString(16);
            while(ret.length < 4){
                    ret = "0"+ret;
            }
            return ret;
    };

    return (
            S4(buf[0])+S4(buf[1])+"-"+S4(buf[2])+"-"+S4(buf[3])+"-"+
            S4(buf[4])+"-"+S4(buf[5])+S4(buf[6])+S4(buf[7])
    );
}
221054
public static byte[] nextID() {
        byte[] ID = new byte[15];
        synchronized (LOCK) {
            long timestamp = System.currentTimeMillis();
            if (timestamp != LAST_TIMESTAMP) {
                LAST_TIMESTAMP = timestamp;
                LAST_SEQUENCE = 0;
                TIMESTAMP_BUFFER[0] = (byte)(timestamp >>> 48);
                TIMESTAMP_BUFFER[1] = (byte)(timestamp >>> 40);
                TIMESTAMP_BUFFER[2] = (byte)(timestamp >>> 32);
                TIMESTAMP_BUFFER[3] = (byte)(timestamp >>> 24);
                TIMESTAMP_BUFFER[4] = (byte)(timestamp >>> 16);
                TIMESTAMP_BUFFER[5] = (byte)(timestamp >>>  8);
                TIMESTAMP_BUFFER[6] = (byte)(timestamp >>>  0);
            } else if (++LAST_SEQUENCE == 0) {
                throw new RuntimeException("Same ID generated in a single milliscond!");
            }
            ByteBuffer bb = ByteBuffer.wrap(ID);
            bb.put(TIMESTAMP_BUFFER);
            bb.put(MAC);
            bb.putShort(LAST_SEQUENCE);
        }
        return ID;
    }
672046
function KdbxUuid(ab) {
    if (ab === undefined) {
        ab = new ArrayBuffer(UuidLength);
    }
    if (typeof ab === 'string') {
        ab = ByteUtils.base64ToBytes(ab);
    }
    this.id = ab.byteLength === 16 ? ByteUtils.bytesToBase64(ab) : undefined;
    this.empty = true;
    if (ab) {
        var bytes = new Uint8Array(ab);
        for (var i = 0, len = bytes.length; i < len; i++) {
            if (bytes[i] !== 0) {
                this.empty = false;
                return;
            }
        }
    }
}
549269
def generate_128bit_trace_id(self):
        
        if 'generate_128bit_trace_id' in self.config:
            return get_boolean(self.config['generate_128bit_trace_id'], False)
        return os.getenv('JAEGER_TRACEID_128BIT') == 'true'
867556
def _idx_to_bits(self, i):
    """"""
    bits = bin(i)[2:].zfill(self.nb_hyperplanes)  # Pad the bits str with 0
    return [-1.0 if b == "0" else 1.0 for b in bits]
884099
def int2base36(n):
    
    assert isinstance(n, (int, long))
    c = '0123456789abcdefghijklmnopqrstuvwxyz'
    if n < 0:
        return '-' + int2base36(-n)
    elif n < 36:
        return c[n]
    b36 = ''
    while n != 0:
        n, i = divmod(n, 36)
        b36 = c[i] + b36
    return b36
884703
function generateNewId() {
        var i = 0;
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            var r = rng(i++) % 16 | 0,
                v = c == 'x' ? r : r & 0x3 | 0x8;
            return v.toString(16);
        });
    }