using System; using System.Diagnostics; using System.IO; using System.Security.Cryptography; using ZstdSharp; using ZstdSharp.Unsafe; namespace zstdtestByteType { internal class Program { static void Main(string[] args) { byte[] mIn = File.ReadAllBytes("test1.in"); for (int l = 0; l < 100; l++) { int numberOfWorkers = 8; Stopwatch sw = new Stopwatch(); sw.Start(); Console.WriteLine($"Testing with {numberOfWorkers} threads"); using (MemoryStream sOut = new MemoryStream()) { Compressor c = new Compressor(1); c.SetParameter(ZSTD_cParameter.ZSTD_c_nbWorkers, numberOfWorkers); using (var zOut = new ZstdSharp.CompressionStream(sOut, c)) { zOut.Write(mIn, 0, mIn.Length); // Remove this Flush and the problem goes away. zOut.Flush(); zOut.Close(); } sw.Stop(); Console.WriteLine($"Time: {sw.ElapsedMilliseconds}ms"); byte[] mOut = sOut.ToArray(); Console.WriteLine($"Output Length {mOut.Length}"); byte[] last6 = new byte[6]; for (int j = 0; j < 6; j++) last6[j] = mOut[mOut.Length - 6 + j]; if (last6[3] == 1 && last6[4] == 0 && last6[5] == 0) Console.ForegroundColor = ConsoleColor.Green; else Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Last 6 byte {BitConverter.ToString(last6)}"); using (SHA1 sha1 = SHA1.Create()) { sha1.TransformFinalBlock(mOut, 0, mOut.Length); Console.WriteLine($"Output SHA1 {BitConverter.ToString(sha1.Hash).Replace("-", "")}\n"); } Console.ForegroundColor = ConsoleColor.White; } } } } }