Compress gzip/Deflate string with golang

29 views Asked by At

I can't correctly compress strings the same way I can in C#.

I have this line:

text:= "Stories often have a moral or message."

Am use C#:

public static byte[] Deflate(byte[] bArr)
{

    MemoryStream mm = new MemoryStream();
    using (ZlibStream zlib = new ZlibStream(mm, Ionic.Zlib.CompressionMode.Compress))
    {
        zlib.Write(bArr, 0, bArr.Length);
        zlib.Close();

    }
    return mm.ToArray();
}

C# result: eJwLLskvykwtVshPK0nNU8hILEtVSFTIzS9KzFHIL1LITS0uTkxP1QMAEwkN2g==

But Golang Deflate Compress gives me this result:

eJwKLskvykwtVshPK0nNU8hILEtVSFTIzS9KzFHIL1LITS0uTkxP1QMEAAD//xMJDdo=

What is the problem and how can I compress in Golang the same way as in C#?

0

There are 0 answers