Pad until the packet length is a multiple of 8 (bytes).
771955
def _complete_last_byte(self, packet):
        """"""
        padded_size = self.get_size()
        padding_bytes = padded_size - len(packet)
        if padding_bytes > 0:
            packet += Pad(padding_bytes).pack()
        return packet
916130
public static void writeShortLength(ByteBuffer bb, int length)
    {
        bb.put((byte) ((length >> 8) & 0xFF));
        bb.put((byte) (length & 0xFF));
    }
134241
function pad(val, len) {
        val = val.toString();
        var padded = [];

        for (var i = 0, j = Math.max(len - val.length, 0); i < j; i++) {
            padded.push('0');
        }

        padded.push(val);
        return padded.join('');
    }
281671
def pad(segment, size):
    
    for i in range(size - len(segment)):
        segment.append(0)

    assert len(segment) == size
1298371
def pad(text, length):
    """"""
    text_length = wcswidth(text)

    if text_length < length:
        return text + ' ' * (length - text_length)

    return text
373649
public static long bytesToLong(byte[] bytes) {
		// Magic number 8 should be defined as Long.SIZE / Byte.SIZE
		long values = 0;
		for (int i = 0; i < 8; i++) {
			values <<= 8;
			values |= (bytes[i] & 0xff);
		}
		return values;
	}
438687
function pad(num, size) { var result
        result = String(num)
        return result.length >= size?  result
             : /* need padding? */     Array(size).join('0') + result
    }
122233
public static String pad(String s, int length)
  {
    if (s.length() < length)
    {
      StringBuffer a = new StringBuffer(length);
      a.append(s);
      for (int i = s.length(); i < length; i++)
      {
        a = a.append(" ");
      }
      return a.toString();
    }
    else if (s.length() > length)
    {
      return s.substring(0, length);
    }
    else
    {
      return s;
    }
  }
489756
def _pad(self, data):
        
        length = 16 - (len(data) % 16)
        data += chr(length)*length
        return data
627429
def _long2bytes(n, blocksize=0):
    

    # After much testing, this algorithm was deemed to be the fastest.
    s = ''
    pack = struct.pack
    while n > 0:
        ### CHANGED FROM '>I' TO '<I'. (DCG)
        s = pack('<I', n & 0xffffffffL) + s
        ### --------------------------
        n = n >> 32

    # Strip off leading zeros.
    for i in range(len(s)):
        if s[i] <> '\000':
            break
    else:
        # Only happens when n == 0.
        s = '\000'
        i = 0

    s = s[i:]

    # Add back some pad bytes. This could be done more efficiently
    # w.r.t. the de-padding being done above, but sigh...
    if blocksize > 0 and len(s) % blocksize:
        s = (blocksize - len(s) % blocksize) * '\000' + s

    return s
124064
def _pad_block(self, handle):
        ''''''
        extra = handle.tell() % 512
        if extra:
            handle.write(b'\x00' * (512 - extra))
348110
def _pad_data(self, max_len=None):
        
        if not max_len:
            max_len = max([len(x) for x in self._data])
        for _, col in enumerate(self._data):
            col.extend([None] * (max_len - len(col)))
865010
private void xorPayloadToHmacPad(byte[] workBytes) {
    int payloadSize = workBytes.length - OVERHEAD_SIZE;
    int sections = (payloadSize + COUNTER_PAGESIZE - 1) / COUNTER_PAGESIZE;
    checkArgument(sections <= COUNTER_SECTIONS, "Payload is %s bytes, exceeds limit of %s",
        payloadSize, COUNTER_PAGESIZE * COUNTER_SECTIONS);

    Mac encryptionHmac = createMac();

    byte[] pad = new byte[COUNTER_PAGESIZE + 3];
    int counterSize = 0;

    for (int section = 0; section < sections; ++section) {
      int sectionBase = section * COUNTER_PAGESIZE;
      int sectionSize = min(payloadSize - sectionBase, COUNTER_PAGESIZE);

      try {
        encryptionHmac.reset();
        encryptionHmac.init(keys.getEncryptionKey());
        encryptionHmac.update(workBytes, INITV_BASE, INITV_SIZE);
        if (counterSize != 0) {
          encryptionHmac.update(pad, COUNTER_PAGESIZE, counterSize);
        }
        encryptionHmac.doFinal(pad, 0);
      } catch (ShortBufferException | InvalidKeyException e) {
        throw new IllegalStateException(e);
      }

      for (int i = 0; i < sectionSize; ++i) {
        workBytes[PAYLOAD_BASE + sectionBase + i] ^= pad[i];
      }

      Arrays.fill(pad, 0, COUNTER_PAGESIZE, (byte) 0);

      if (counterSize == 0 || ++pad[COUNTER_PAGESIZE + counterSize - 1] == 0) {
        ++counterSize;
      }
    }
  }
251739
def padto8(data):
    """"""
    length = len(data)
    return data + b'\xdb' * (roundto8(length) - length)
91236
protected static final int nextStringLength(byte[] bytes, int startPos, int length, char delimiter) {
		if (length <= 0) {
			throw new IllegalArgumentException("Invalid input: Empty string");
		}
		int limitedLength = 0;
		final byte delByte = (byte) delimiter;

		while (limitedLength < length && bytes[startPos + limitedLength] != delByte) {
			limitedLength++;
		}

		return limitedLength;
	}
1041339
function pad(num, size) {
	var s = num+"";
	while (s.length < size) {
		s = "0" + s;
	}
	return s;
}
1102714
def pad(self, data, block_size):
		
		pad_byte = block_size - (len(data) % block_size)
		return data + bytes([pad_byte] * pad_byte)