Decompress part of a complete Brotli-compressed string.

        :param data: A bytestring containing Brotli-compressed data.
        :returns: A bytestring containing the decompressed data.
552787
def decompress(self, data):
        
        chunks = []

        available_in = ffi.new("size_t *", len(data))
        in_buffer = ffi.new("uint8_t[]", data)
        next_in = ffi.new("uint8_t **", in_buffer)

        while True:
            # Allocate a buffer that's hopefully overlarge, but if it's not we
            # don't mind: we'll spin around again.
            buffer_size = 5 * len(data)
            available_out = ffi.new("size_t *", buffer_size)
            out_buffer = ffi.new("uint8_t[]", buffer_size)
            next_out = ffi.new("uint8_t **", out_buffer)

            rc = lib.BrotliDecoderDecompressStream(self._decoder,
                                                   available_in,
                                                   next_in,
                                                   available_out,
                                                   next_out,
                                                   ffi.NULL)

            # First, check for errors.
            if rc == lib.BROTLI_DECODER_RESULT_ERROR:
                error_code = lib.BrotliDecoderGetErrorCode(self._decoder)
                error_message = lib.BrotliDecoderErrorString(error_code)
                raise Error(
                    "Decompression error: %s" % ffi.string(error_message)
                )

            # Next, copy the result out.
            chunk = ffi.buffer(out_buffer, buffer_size - available_out[0])[:]
            chunks.append(chunk)

            if rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:
                assert available_in[0] == 0
                break
            elif rc == lib.BROTLI_DECODER_RESULT_SUCCESS:
                break
            else:
                # It's cool if we need more output, we just loop again.
                assert rc == lib.BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT

        return b''.join(chunks)
397123
def to_bytes(data):
    
    if isinstance(data, six.string_types) and not isinstance(data, bytes):
        return codecs.encode(data, aws_encryption_sdk.internal.defaults.ENCODING)
    return data
1213682
def unpack(cls, data):
        
        header, data = APPHeader.unpack(data)

        if len(data) < header.payload_length:
            raise ProtocolViolation("Payload too small")
        payload = data[:header.payload_length]
        body = cls()
        body._header = header
        body._payload = payload
        return body, data[header.payload_length:]
629416
def decrypt(self, data, decode=False):
		

		#result = self.cipher().decrypt(data)
		result = self.cipher().decrypt_block(data)

		padding = self.mode().padding()
		if padding is not None:
			result = padding.reverse_pad(result, WAESMode.__data_padding_length__)

		return result.decode() if decode else result
368075
def cdata (self, data):
        
        data = data.encode(self.encoding, "ignore")
        self.fd.write("<![CDATA[%s]]>" % data)
964228
def decode(self, data):
        
        return Zchunk(lib.zarmour_decode(self._as_parameter_, data), True)
1024410
def unpack_chunk(chunk_data: str) -> bytes:
    

    if not chunk_data:
        return b''

    chunk_compressed = binascii.a2b_base64(chunk_data.encode('utf-8'))
    return zlib.decompress(chunk_compressed)
702380
def _decompress(self, fp):
        
        decompressor = zlib.decompressobj()
        if self.stream:
            return Proxy(decompressor.decompress, fp)
        else:
            out = io.BytesIO(decompressor.decompress(fp.read()))
            out.write(decompressor.flush())
            out.seek(0)
            return out
673821
def compress(info):
    
    if PY3:
        file_obj = BytesIO()
    else:
        file_obj = StringIO()

    with zipfile.ZipFile(
            file_obj,
            mode='w',
            compression=zipfile.ZIP_DEFLATED) as zipper:
        for name, data in info.items():
            if hasattr(data, 'read'):
                # if we were passed a file object, read it
                data = data.read()
            zipper.writestr(name, data)
    file_obj.seek(0)
    compressed = file_obj.read()
    return compressed
320516
def decompress(data):
    
    d = Decompressor()
    data = d.decompress(data)
    d.finish()
    return data
141611
def _string_to_byte_list(self, data):
        
        bytes_length = 16

        m = self.digest()
        m.update(str.encode(data))
        hex_digest = m.hexdigest()

        return list(int(hex_digest[num * 2:num * 2 + 2], bytes_length)
                    for num in range(bytes_length))
1010027
def compress(data, format=FORMAT_XZ, check=-1, preset=None, filters=None):
    
    comp = LZMACompressor(format, check, preset, filters)
    return comp.compress(data) + comp.flush()
213396
def decompress(compressed_data):
    """"""
    raw_data = []

    index = 0

    while index < len(compressed_data):
        current = compressed_data[index]
        index += 1

        if current == RLE_BYTE:
            directive = compressed_data[index]
            index += 1

            if directive == RLE_BYTE:
                raw_data.append(RLE_BYTE)
            else:
                count = compressed_data[index]
                index += 1

                raw_data.extend([directive] * count)
        elif current == SPECIAL_BYTE:
            directive = compressed_data[index]
            index += 1

            if directive == SPECIAL_BYTE:
                raw_data.append(SPECIAL_BYTE)
            elif directive == DEFAULT_WAVE_BYTE:
                count = compressed_data[index]
                index += 1

                raw_data.extend(DEFAULT_WAVE * count)
            elif directive == DEFAULT_INSTR_BYTE:
                count = compressed_data[index]
                index += 1

                raw_data.extend(DEFAULT_INSTRUMENT_FILEPACK * count)
            elif directive == EOF_BYTE:
                assert False, ("Unexpected EOF command encountered while "
                               "decompressing")
            else:
                assert False, "Countered unexpected sequence 0x%02x 0x%02x" % (
                    current, directive)
        else:
            raw_data.append(current)

    return raw_data
287289
function decompress(data) {
    var input = new Uint8Array(data);
    var output = [];

    var ip = 0;
    var op = 0;

    do {
        var ctrl = input[ip++];

        if (ctrl < (1 << 5)) { /* literal run */
            ctrl++;

            if (ip + ctrl > input.length) {
                throw new Error('Invalid input'); 
            }

            while (ctrl--) {
                output[op++] = input[ip++];
            }
        } else { /* back reference */
            var len = ctrl >> 5;
            var ref =  op - ((ctrl & 0x1f) << 8) - 1;

            if (ip >= input.length) {
                throw new Error('Invalid input');
            }

            if (len == 7) {
                len += input[ip++];

                if (ip >= input.length) {
                    throw new Error('Invalid input');
                }
            }

            ref -= input[ip++];

            if (ref < 0) {
                throw new Error('Invalid input');
            }

            len += 2;

            do {
                output[op++] = output[ref++];
            } while (--len);
        }
    } while (ip < input.length);

    // Return a Buffer if it exists (say in node), otherwise just
    // use a normal Uint8Array.
    if (typeof Buffer !== 'undefined') {
        return new Buffer(output);
    } else {
        var res = new Uint8Array(output.length);
        res.set(output);
        return res;
    }
}
1343835
public static final byte[] compress(byte[] data, int level) throws IOException {
		final Deflater deflater = new Deflater(level, true);
		deflater.setInput(data);
		deflater.finish();
		final byte[] buffer = new byte[data.length + 128];
		final int length = deflater.deflate(buffer);
		final byte[] compressed = new byte[length];
		System.arraycopy(buffer, 0, compressed, 0, length);
		return compressed;
	}
816228
def compress(data, compresslevel=9):
    
    buf = io.BytesIO()
    with GzipFile(fileobj=buf, mode='wb', compresslevel=compresslevel) as f:
        f.write(data)
    return buf.getvalue()
437125
def decompress(ctype, unc_len, data):
    
    if ctype == UBIFS_COMPR_LZO:
        try:
            return lzo.decompress(b''.join((b'\xf0', struct.pack('>I', unc_len), data)))
        except Exception as e:
            error(decompress, 'Warn', 'LZO Error: %s' % e)
    elif ctype == UBIFS_COMPR_ZLIB:
        try:
            return zlib.decompress(data, -11)
        except Exception as e:
            error(decompress, 'Warn', 'ZLib Error: %s' % e)
    else:
        return data