Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.net Deflate / nodejs Deflate Output does not match with golang flate module with level 9 #39095

Closed
ignition123 opened this issue May 15, 2020 · 4 comments

Comments

@ignition123
Copy link

@ignition123 ignition123 commented May 15, 2020

// Golang Sample

  var deflated_data bytes.Buffer
  fl, err := flate.NewWriter(&deflated_data, 9)

if err != nil{

	return nil, errors.New(err.Error())

}

if _, err := fl.Write([]byte("63=FIX3.0|64=127|65=80|4=1000|1=3|7=523630|230=1")); err != nil{
    
	return nil, errors.New(err.Error())

}

if err := fl.Close(); err != nil {
    
    return nil, errors.New(err.Error())

}

    log.Println(deflated_data.Bytes())

// sample output
[4 192 193 13 128 48 20 2 208 141 12 124 90 234 133 171 137 27 56 12 195 251 172 60 239 167 11 245 10 231 212 59 55 186 66 0 101 212 147 61 178 208 17 194 63 0 0 255 255]

.net Sample Code

      private static byte[] Compress(Stream input)
     {
          using(var compressStream = new MemoryStream())
          using(var compressor = new DeflateStream(compressStream, 9))
         {
             input.CopyTo(compressor);
             compressor.Close();
             return compressStream.ToArray();
         }
   }

    Compress("63=FIX3.0|64=127|65=80|4=1000|1=3|7=523630|230=1")

// sample output
13,198,177,13,0,32,12,3,176,143,80,218,64,97,201,138,196,7,28,147,227,193,147,139,218,231,178,193,213,21,57,93,67,11,254,7,224,16,61,53,146,69,56,9,197,3

@seankhliao
Copy link
Contributor

@seankhliao seankhliao commented May 15, 2020

deflate is the underlying algorithm, zlib is the format you want to use compress/zlib

	fl, err := zlib.NewWriterLevel(&deflated_data, 9)
@ignition123
Copy link
Author

@ignition123 ignition123 commented May 15, 2020

With zlib also it's not matching with the .net and nodejs output.

@ignition123
Copy link
Author

@ignition123 ignition123 commented May 15, 2020

Input
"63=FIX3.0|64=127|65=80|4=1000|1=3|7=523630|230=1"

nodejs/.net zlib
120,218,13,198,177,13,0,32,12,3,176,143,80,218,64,97,201,138,196,7,28,147,227,193,147,139,218,231,178,193,213,21,57,93,67,11,254,7,224,16,61,53,146,69,56,9,197,3,213,11,139,37

golang zlib
120 218 4 192 193 13 128 48 20 2 208 141 12 124 90 234 133 171 137 27 56 12 195 251 172 60 239 167 11 245 10 231 212 59 55 186 66 0 101 212 147 61 178 208 17 194 63 0 0 255 255 37 139 11 213

@ignition123
Copy link
Author

@ignition123 ignition123 commented May 15, 2020

Got solution using "github.com/DataDog/czlib" library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.