Net Encryption Library
CompressBytes Method
Example 






KellermanSoftware.NetEncryptionLibrary Namespace > Encryption Class : CompressBytes Method
Compress the passed bytes using the specified compression type
Syntax
'Declaration
 
Public Function CompressBytes( _
   ByVal compressionType As CompressionType, _
   ByVal input() As System.Byte _
) As System.Byte()
'Usage
 
Dim instance As Encryption
Dim compressionType As CompressionType
Dim input() As System.Byte
Dim value() As System.Byte
 
value = instance.CompressBytes(compressionType, input)
public System.byte[] CompressBytes( 
   CompressionType compressionType,
   System.byte[] input
)
public function CompressBytes( 
    compressionType: CompressionType;
    input: System.Bytearray of
): System.array of Byte; 
public function CompressBytes( 
   compressionType : CompressionType,
   input : System.byte[]
) : System.byte[];
public: System.byte[]* CompressBytes( 
   CompressionType compressionType,
   System.byte[]* input
) 
public:
System.array<byte>^ CompressBytes( 
   CompressionType compressionType,
   System.array<byte>^ input
) 

Parameters

compressionType
input
Example
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
byte[] input = new byte[1024];
 
for (int i = 0; i < 1024; i++)
    input[i] = 5;
 
byte[] results = encryption.CompressBytes(CompressionType.GZip, input);
Console.WriteLine("{0} bytes compressed to {1} bytes with GZIP", input.Length, results.Length);
 
results = encryption.CompressBytes(CompressionType.Deflate, input);
Console.WriteLine("{0} bytes compressed to {1} bytes with Deflate", input.Length, results.Length);
 
results = encryption.CompressBytes(CompressionType.MiniLZO, input);
Console.WriteLine("{0} bytes compressed to {1} bytes with MiniLZO", input.Length, results.Length);
Dim encryption As New Encryption() 'Trial Mode
'Dim encryption As New Encryption("place user name here", "place license key here") 'License Mode
 
Dim input(1023) As Byte
 
For i As Integer = 0 To 1023
    input(i) = 5
Next i
 
Dim results() As Byte = encryption.CompressBytes(CompressionType.GZip, input)
Console.WriteLine("{0} bytes compressed to {1} bytes with GZIP", input.Length, results.Length)
 
results = encryption.CompressBytes(CompressionType.Deflate, input)
Console.WriteLine("{0} bytes compressed to {1} bytes with Deflate", input.Length, results.Length)
 
results = encryption.CompressBytes(CompressionType.MiniLZO, input)
Console.WriteLine("{0} bytes compressed to {1} bytes with MiniLZO", input.Length, results.Length)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Encryption Class
Encryption Members