Write a compressing util for gzip files
C# (534 characters)

using System.IO;using B=System.Byte;class X{static void Main(string[]a){var f=File.ReadAllBytes(a[0]);int l=f.Length,i=0,j;var p=new uint[256];for(uint k=0,r=0;k&lt;256;r=++k){for(j=0;j&lt;8;j++)r=r&gt;&gt;1^(r&amp;1)*0xedb88320;p[k]=r;}uint c=~(uint)0,n=c;using(var o=File.Open(a[0]+".gz",FileMode.Create)){o.Write(new B[]{31,139,8,0,0,0,0,0,4,11},0,10);for(;i&lt;l;i++){o.Write(new B[]{(B)(i&lt;l-1?0:1),1,0,254,255,f[i]},0,6);c=p[(c^f[i])&amp;0xFF]^c&gt;&gt;8;}c^=n;o.Write(new[]{(B)c,(B)(c&gt;&gt;8),(B)(c&gt;&gt;16),(B)(c&gt;&gt;24),(B)l,(B)(l&gt;&gt;8),(B)(l&gt;&gt;16),(B)(l&gt;&gt;24)},0,8);}}}


Much more readable:

using System.IO;
using B = System.Byte;
class X
{
    static void Main(string[] a)
    {
        // Read file contents
        var f = File.ReadAllBytes(a[0]);
        int l = f.Length, i = 0, j;

        // Initialise table for CRC hashsum
        var p = new uint[256];
        for (uint k = 0, r = 0; k &lt; 256; r = ++k)
        {
            for (j = 0; j &lt; 8; j++)
                r = r &gt;&gt; 1 ^ (r &amp; 1) * 0xedb88320;
            p[k] = r;
        }

        uint c = ~(uint) 0, n = c;

        // Write the output file
        using (var o = File.Open(a[0] + ".gz", FileMode.Create))
        {
            // gzip header
            o.Write(new B[] { 31, 139, 8, 0, 0, 0, 0, 0, 4, 11 }, 0, 10);
            for (; i &lt; l; i++)
            {
                // deflate block header plus one byte of payload
                o.Write(new B[] { (B) (i &lt; l - 1 ? 0 : 1), 1, 0, 254, 255, f[i] }, 0, 6);
                // Compute CRC checksum
                c = p[(c ^ f[i]) &amp; 0xFF] ^ c &gt;&gt; 8;
            }
            c ^= n;
            o.Write(new[] {
                // CRC checksum
                (B) c, (B) (c &gt;&gt; 8), (B) (c &gt;&gt; 16), (B) (c &gt;&gt; 24),
                // original file size
                (B) l, (B) (l &gt;&gt; 8), (B) (l &gt;&gt; 16), (B) (l &gt;&gt; 24)
            }, 0, 8);
        }
    }
}


Comments:


Expects path to file as first command-line argument.
Output file is input file + .gz.
I am not using any libraries to do the gzip, deflate or CRC32. It’s all in there.
This “compressor” increases the filesize by a factor of 6. But it’s in valid gzip format!
Tested using GNU gunzip and WinRAR.