public static class DeflateStreamExtensions {
public static UInt32 ReadUInt32(this DeflateStream stream) {
int a = stream.ReadByte();
int b = stream.ReadByte();
return (UInt32)((a >> 8) + b);
public static class GZipStreamExtensions {
public static UInt32 ReadUInt32(this GZipStream stream) {
int a = stream.ReadByte();
int b = stream.ReadByte();
return (UInt32)((a >> 8) + b);
void Decode(Stream input, Stream output);
public sealed class Base85Decoder : IDecoder {
private string _base85alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%()*+,-./:;=?@[]^_{}";
public void Decode(Stream input, Stream output) {
int inputSize = (int)input.Length;
input.Seek(0, SeekOrigin.Begin);
char c = (char)input.ReadByte();
value = Convert.ToUInt32(_base85alphabet.IndexOf(c)) * Convert.ToUInt32(Math.Pow(85, 4));
c = (char)input.ReadByte();
value += Convert.ToUInt32(_base85alphabet.IndexOf(c)) * Convert.ToUInt32(Math.Pow(85, 3));
c = (char)input.ReadByte();
value += Convert.ToUInt32(_base85alphabet.IndexOf(c)) * Convert.ToUInt32(Math.Pow(85, 2));
c = (char)input.ReadByte();
value += Convert.ToUInt32(_base85alphabet.IndexOf(c)) * Convert.ToUInt32(Math.Pow(85, 1));
value += Convert.ToUInt32(_base85alphabet.IndexOf(c));
output.WriteByte(Convert.ToByte((value >> 24) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 16) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 8) & 0xFF));
output.WriteByte(Convert.ToByte(value & 0xFF));
output.WriteByte(Convert.ToByte((value >> 24) & 0xFF));
value += 84 * Convert.ToUInt32(Math.Pow(85, 2)) + 84 * 85 + 84;
output.WriteByte(Convert.ToByte((value >> 24) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 16) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 24) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 16) & 0xFF));
output.WriteByte(Convert.ToByte((value >> 8) & 0xFF));
output.Seek(0, SeekOrigin.Begin);
public static void Main() {
string str_in = "c-rMwTTj$L6h2+srIgDCmzW=CjUir:YF0o)jES;!Tf}4dy8617cG#]#wm2.{pN61Zp8Z3MzsxgJRu,ZjfqmOazRvlkGw00tdZwAll]Z!pO#B*#=ifTTy1x4v(fDW1s*2=@tZ3g7KC)bznhG$^*/KADlR@pY1H]ltnhvm@g)5hD!XZ[2wJc5fzR+(RwgJBnOsahR:/H+$vkxJCz_W38L{wq[/^{J$mFCq^dpa}RarALyQrU_mQz)9HHWfcMAtU+TNo6li9*f@zj7^;cmjv5x!rt;JVQ5DoF-lCDmTi,vLWVug?O=RGFiu7j+.S%2rMFTVvt(6.7}gj5]Qv;0HHdD9=pmGsnns5HI/)1P%O+LiwzUyP,@R8[L@0]*YtarFedjh/+^#M[J?7WjSSg4TH{vFCI,9yO2RxpAQMkwp7x}.j=]K-va3bEY;QT%zwNXPp]VoVQX7sbNDN@{qKzo3Eih[^xOUb2leKNt{Xp?B}o5$jq/h]0yDXaz_d%C,YUzwjHx,kMpwg#8B93p;^m{BiRgV{{o;mp7d=%pKgh$SQ5w@hjNqCG-9M]%DMv2!rmK1TB=XbzUYF9hf}w1j1UkDkI5WQ5Z!V*.]z#d7uKv7m6@.E[5MMYV3Ksa-xtoX=RvANqgiYwI/{BNjhnyNnFGzRz+Ej;ScCRhAS{z9M-R3oc;#R#s$4C2fZZ-y:]j7FKZGDr-c1=+sE9=l10?SnTm(QyrqgRvnY@hML6Hq^:#H;@md3FAQ#l;F@aw(LCd)tdb+bzkqJ2]5Lj?vuYYr#h3W@Y.-{(w{@7DOIhfOl%Eil9,z@iJ5}7w?wLaLoav5}A;x}oGSh!1rH^7+2d}QOkfxkbm%X#A02%PyH-UeZySDZRE}Vz0";
using (MemoryStream input = new MemoryStream(Encoding.ASCII.GetBytes(str_in)))
using (MemoryStream output = new MemoryStream())
new Base85Decoder().Decode(input, output);
MemoryStream decompressed = new MemoryStream();
using (ZlibStream ds = new ZlibStream(output, CompressionMode.Decompress)) {