bytes 1024-2047/128144
543017
public static ByteRange parse(String headerValue) {
        if (headerValue == null || headerValue.length() == 0) {
            return null;
        }
        try {
            int idx = 0;
            byte[] arr = headerValue.getBytes();
            int len = headerValue.length();
            while (idx < len && Character.isWhitespace(arr[idx] & 255)) {
                ++idx;
            }
            int pIdx = idx;
            while (idx < len && Character.isLetter(arr[idx] & 255)) {
                ++idx;
            }
            String type = headerValue.substring(pIdx, idx).toLowerCase();
            if (idx == len || arr[idx] != ' ') {
                return null;
            }
            while (idx < len && Character.isWhitespace(arr[idx] & 255)) {
                ++idx;
            }
            pIdx = idx;
            while (idx < len && arr[idx] != '-') {
                ++idx;
            }
            long from = Long.parseLong(headerValue.substring(pIdx, idx));
            if (idx == len || arr[idx] != '-') {
                return null;
            }
            pIdx = ++idx;
            while (idx < len && arr[idx] != '/') {
                ++idx;
            }
            long to = Long.parseLong(headerValue.substring(pIdx, idx));
            if (idx == len || arr[idx] != '/') {
                return null;
            }
            pIdx = ++idx;
            while (idx < len && Character.isDigit(arr[idx])) {
                ++idx;
            }
            long contentLength = Long.parseLong(headerValue.substring(pIdx, idx));
            ByteRange byteRange = new ByteRange();
            byteRange.type = type;
            byteRange.from = from;
            byteRange.to = to;
            byteRange.contentLength = contentLength;
            return byteRange;
        }
        catch (NumberFormatException e) {
            return null;
        }
    }
578229
def human_to_bytes(size):
    '''
    
    '''
    sbytes = size[:-1]
    unit = size[-1]
    if sbytes.isdigit():
        sbytes = int(sbytes)
        if unit == 'P':
            sbytes *= 1125899906842624
        elif unit == 'T':
            sbytes *= 1099511627776
        elif unit == 'G':
            sbytes *= 1073741824
        elif unit == 'M':
            sbytes *= 1048576
        else:
            sbytes = 0
    else:
        sbytes = 0
    return sbytes
399074
def offset_byte_in_data(target_data, offset, target_byte_pos, readable = False, wraparound = False):
    
    byte_pos = target_byte_pos * 2
    prefix = target_data[:byte_pos]
    suffix = target_data[byte_pos+2:]
    target_byte = target_data[byte_pos:byte_pos+2]
    int_value = int(target_byte, 16)
    int_value += offset

    # Wraparound
    if int_value > 255 and wraparound:
        int_value -= 256

    # Extract readable char for analysis
    if readable:
        if int_value < 256 and int_value > 0:
            offset_byte = get_readable_string(int_value)
        else:
            offset_byte = int_to_padded_hex_byte(int_value)
    else:
        offset_byte = int_to_padded_hex_byte(int_value)

    return ''.join([prefix, offset_byte, suffix])
690119
static long readEpochSec(DataInput in) throws IOException {
        int hiByte = in.readByte() & 255;
        if (hiByte == 255) {
            return in.readLong();
        } else {
            int midByte = in.readByte() & 255;
            int loByte = in.readByte() & 255;
            long tot = ((hiByte << 16) + (midByte << 8) + loByte);
            return (tot * 900) - 4575744000L;
        }
    }
188615
def to_bytes(s, encoding="utf-8"):
    """"""
    if isinstance(s, six.binary_type):
        return s
    if six.PY3:
        return bytes(s, encoding)
    return s.encode(encoding)
1153937
def endianSwapU16(bytes):
    """"""
    for b in range(0, len(bytes), 2):
        bytes[b], bytes[b + 1] = bytes[b + 1], bytes[b]
    return bytes
621522
def get_bytes(self, *args, **kwargs):
        
        return super(XClient, self).get(*args, **kwargs)
1275684
def pretty_bytes(num):
    
    for unit in ['', 'KB', 'MB', 'GB']:
        if num < 1024.0:
            if unit == '':
                return "%d" % (num)
            else:
                return "%3.1f%s" % (num, unit)
        num /= 1024.0
    return "%3.1f%s" % (num, 'TB')
1281857
private static long bytesToLong(byte[] address) {
        long ipnum = 0;
        for (int i = 0; i < 4; ++i) {
            long y = address[i];
            if (y < 0) {
                y += 256;
            }
            ipnum += y << ((3 - i) * 8);
        }
        return ipnum;
    }
1058146
def hash160(msg_bytes):
    '''
    
    '''
    h = hashlib.new('ripemd160')
    if 'decred' in riemann.get_current_network_name():
        h.update(blake256(msg_bytes))
        return h.digest()
    h.update(sha256(msg_bytes))
    return h.digest()
916698
private int uint16FromData(int offset) {
        return twoBytesToInt(
                Arrays.copyOfRange(data(), offset, offset + 2),
                Constants.CC2540_BYTE_ORDER
        );
    }
418194
private byte getFlagByte()
	{
		byte ret = 0;

		if (unsynchronisation) ret |= 0x80;
		if (extended) ret |= 0x40;
		if (experimental) ret |= 0x20;
		if (footer) ret |= 0x10;

		return ret;
	}
1031844
def bytes2guid(s):
    """"""

    assert isinstance(s, bytes)

    u = struct.unpack
    v = []
    v.extend(u("<IHH", s[:8]))
    v.extend(u(">HQ", s[8:10] + b"\x00\x00" + s[10:]))
    return "%08X-%04X-%04X-%04X-%012X" % tuple(v)
1324660
def byte_str(nBytes, unit='bytes', precision=2):
    
    #return (nBytes * ureg.byte).to(unit.upper())
    if unit.lower().startswith('b'):
        nUnit = nBytes
    elif unit.lower().startswith('k'):
        nUnit =  nBytes / (2.0 ** 10)
    elif unit.lower().startswith('m'):
        nUnit =  nBytes / (2.0 ** 20)
    elif unit.lower().startswith('g'):
        nUnit = nBytes / (2.0 ** 30)
    elif unit.lower().startswith('t'):
        nUnit = nBytes / (2.0 ** 40)
    else:
        raise NotImplementedError('unknown nBytes=%r unit=%r' % (nBytes, unit))
    return repr2(nUnit, precision=precision) + ' ' + unit
97279
def bytes(self):
        """"""
        byteout = bytearray()
        for i in range(1, 15):
            key = 'd' + str(i)
            if self._userdata[key] is not None:
                byteout.append(self._userdata[key])
            else:
                byteout.append(0x00)
        return byteout
325555
function bytesToWords(bytes) {
	var bytes_count = bytes.length,
	    bits_count = bytes_count << 3,
	    words = new Uint32Array((bytes_count + 64) >>> 6 << 4);
	for (var i = 0, n = bytes.length; i < n; ++i)
		words[i >>> 2] |= bytes.charCodeAt(i) << ((i & 3) << 3);
	words[bytes_count >> 2] |= 0x80 << (bits_count & 31); // append "1" bit to message
	words[words.length - 2] = bits_count;
	return words;
}
685634
def get_bytes(num_bytes):
    
    # Is this the way to do it?
    #s = c_ubyte()
    # Or this?
    s = create_string_buffer(num_bytes)
    # Used to keep track of status. 1 = success, 0 = error.
    ok = c_int()
    # Provider?
    hProv = c_ulong()

    ok = windll.Advapi32.CryptAcquireContextA(byref(hProv), None, None, PROV_RSA_FULL, 0)
    ok = windll.Advapi32.CryptGenRandom(hProv, wintypes.DWORD(num_bytes), cast(byref(s), POINTER(c_byte)))

    return s.raw