Exemple #1
0
 internal Dictionary <ChecksumType, string> End() => new Dictionary <ChecksumType, string>
 {
     [ChecksumType.Crc32]  = _crc32Ctx.End(),
     [ChecksumType.Md5]    = _md5Ctx.End(),
     [ChecksumType.Sha1]   = _sha1Ctx.End(),
     [ChecksumType.Sha256] = _sha256Ctx.End(),
     [ChecksumType.Sha384] = _sha384Ctx.End(),
     [ChecksumType.Sha512] = _sha512Ctx.End()
 };
Exemple #2
0
        public static BenchmarkResults Do(int bufferSize, int blockSize)
        {
            BenchmarkResults results = new BenchmarkResults
            {
                Entries      = new Dictionary <string, BenchmarkEntry>(),
                MinMemory    = long.MaxValue,
                MaxMemory    = 0,
                SeparateTime = 0
            };
            MemoryStream ms  = new MemoryStream(bufferSize);
            Random       rnd = new Random();
            DateTime     start;
            DateTime     end;

            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Writing block {0} of {1} with random data.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                rnd.NextBytes(tmp);
                ms.Write(tmp, 0, blockSize);
            }

            EndProgress();
            end = DateTime.Now;

            results.FillTime  = (end - start).TotalSeconds;
            results.FillSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;

            ms.Seek(0, SeekOrigin.Begin);
            long mem = GC.GetTotalMemory(false);

            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Reading block {0} of {1}.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
            }

            EndProgress();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.ReadTime  = (end - start).TotalSeconds;
            results.ReadSpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;

            #region Adler32
            IChecksum ctx = new Adler32Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with Adler32.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("Adler32",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion Adler32

            #region Fletcher16
            ctx = new Fletcher16Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with Fletcher-16.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("Fletcher16",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion Fletcher16

            #region Fletcher32
            ctx = new Fletcher32Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with Fletcher-32.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("Fletcher32",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion Fletcher32

            #region CRC16
            ctx = new Crc16Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with CRC16.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("CRC16",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion CRC16

            #region CRC32
            ctx = new Crc32Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with CRC32.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("CRC32",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion CRC32

            #region CRC64
            ctx = new Crc64Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with CRC64.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("CRC64",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion CRC64

            #region MD5
            ctx = new Md5Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with MD5.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("MD5",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion MD5

            #if !NETSTANDARD2_0
            #region RIPEMD160
            ctx = new Ripemd160Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with RIPEMD160.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("RIPEMD160",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion RIPEMD160
            #endif

            #region SHA1
            ctx = new Sha1Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with SHA1.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("SHA1",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion SHA1

            #region SHA256
            ctx = new Sha256Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with SHA256.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("SHA256",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion SHA256

            #region SHA384
            ctx = new Sha384Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with SHA384.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("SHA384",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion SHA384

            #region SHA512
            ctx = new Sha512Context();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with SHA512.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("SHA512",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion SHA512

            #region SpamSum
            ctx = new SpamSumContext();
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Checksumming block {0} of {1} with SpamSum.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                ctx.Update(tmp);
            }

            EndProgress();
            ctx.End();
            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.Entries.Add("SpamSum",
                                new BenchmarkEntry
            {
                TimeSpan = (end - start).TotalSeconds,
                Speed    = bufferSize / 1048576.0 / (end - start).TotalSeconds
            });
            results.SeparateTime += (end - start).TotalSeconds;
            #endregion SpamSum

            #region Entropy
            ulong[] entTable = new ulong[256];
            ms.Seek(0, SeekOrigin.Begin);
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }
            start = DateTime.Now;
            InitProgress();
            for (int i = 0; i < bufferSize / blockSize; i++)
            {
                UpdateProgress("Entropying block {0} of {1}.", i + 1, bufferSize / blockSize);
                byte[] tmp = new byte[blockSize];
                ms.Read(tmp, 0, blockSize);
                foreach (byte b in tmp)
                {
                    entTable[b]++;
                }
            }

            EndProgress();

            end = DateTime.Now;
            mem = GC.GetTotalMemory(false);
            if (mem > results.MaxMemory)
            {
                results.MaxMemory = mem;
            }
            if (mem < results.MinMemory)
            {
                results.MinMemory = mem;
            }

            results.EntropyTime  = (end - start).TotalSeconds;
            results.EntropySpeed = bufferSize / 1048576.0 / (end - start).TotalSeconds;
            #endregion Entropy

            /*
             #region Multitasking
             * start                 = DateTime.Now;
             * Checksum allChecksums = new Checksum();
             * InitProgress();
             * for(int i = 0; i < bufferSize / blockSize; i++)
             * {
             *  UpdateProgress("Checksumming block {0} of {1} with all algorithms at the same time.", i + 1,
             *                 bufferSize / blockSize);
             *  byte[] tmp = new byte[blockSize];
             *  ms.Read(tmp, 0, blockSize);
             *
             *  allChecksums.Update(tmp);
             * }
             *
             * EndProgress();
             *
             * allChecksums.End();
             * end                                           = DateTime.Now;
             * mem                                           = GC.GetTotalMemory(false);
             * if(mem > results.MaxMemory) results.MaxMemory = mem;
             * if(mem < results.MinMemory) results.MinMemory = mem;
             *
             * results.TotalTime  = (end - start).TotalSeconds;
             * results.TotalSpeed = bufferSize / 1048576.0 / results.TotalTime;
             #endregion
             */
            results.SeparateSpeed = bufferSize / 1048576.0 / results.SeparateTime;

            return(results);
        }
Exemple #3
0
        internal static List <ChecksumType> GetChecksums(byte[] data)
        {
            Adler32Context   adler32ctxData   = new Adler32Context();
            Crc16Context     crc16ctxData     = new Crc16Context();
            Crc32Context     crc32ctxData     = new Crc32Context();
            Crc64Context     crc64ctxData     = new Crc64Context();
            Md5Context       md5ctxData       = new Md5Context();
            Ripemd160Context ripemd160ctxData = new Ripemd160Context();
            Sha1Context      sha1ctxData      = new Sha1Context();
            Sha256Context    sha256ctxData    = new Sha256Context();
            Sha384Context    sha384ctxData    = new Sha384Context();
            Sha512Context    sha512ctxData    = new Sha512Context();
            SpamSumContext   ssctxData        = new SpamSumContext();

            Thread adlerThreadData     = new Thread(updateAdler);
            Thread crc16ThreadData     = new Thread(updateCRC16);
            Thread crc32ThreadData     = new Thread(updateCRC32);
            Thread crc64ThreadData     = new Thread(updateCRC64);
            Thread md5ThreadData       = new Thread(updateMD5);
            Thread ripemd160ThreadData = new Thread(updateRIPEMD160);
            Thread sha1ThreadData      = new Thread(updateSHA1);
            Thread sha256ThreadData    = new Thread(updateSHA256);
            Thread sha384ThreadData    = new Thread(updateSHA384);
            Thread sha512ThreadData    = new Thread(updateSHA512);
            Thread spamsumThreadData   = new Thread(updateSpamSum);

            adlerPacket     adlerPktData     = new adlerPacket();
            crc16Packet     crc16PktData     = new crc16Packet();
            crc32Packet     crc32PktData     = new crc32Packet();
            crc64Packet     crc64PktData     = new crc64Packet();
            md5Packet       md5PktData       = new md5Packet();
            ripemd160Packet ripemd160PktData = new ripemd160Packet();
            sha1Packet      sha1PktData      = new sha1Packet();
            sha256Packet    sha256PktData    = new sha256Packet();
            sha384Packet    sha384PktData    = new sha384Packet();
            sha512Packet    sha512PktData    = new sha512Packet();
            spamsumPacket   spamsumPktData   = new spamsumPacket();

            adler32ctxData.Init();
            adlerPktData.context = adler32ctxData;
            crc16ctxData.Init();
            crc16PktData.context = crc16ctxData;
            crc32ctxData.Init();
            crc32PktData.context = crc32ctxData;
            crc64ctxData.Init();
            crc64PktData.context = crc64ctxData;
            md5ctxData.Init();
            md5PktData.context = md5ctxData;
            ripemd160ctxData.Init();
            ripemd160PktData.context = ripemd160ctxData;
            sha1ctxData.Init();
            sha1PktData.context = sha1ctxData;
            sha256ctxData.Init();
            sha256PktData.context = sha256ctxData;
            sha384ctxData.Init();
            sha384PktData.context = sha384ctxData;
            sha512ctxData.Init();
            sha512PktData.context = sha512ctxData;
            ssctxData.Init();
            spamsumPktData.context = ssctxData;

            adlerPktData.data = data;
            adlerThreadData.Start(adlerPktData);
            crc16PktData.data = data;
            crc16ThreadData.Start(crc16PktData);
            crc32PktData.data = data;
            crc32ThreadData.Start(crc32PktData);
            crc64PktData.data = data;
            crc64ThreadData.Start(crc64PktData);
            md5PktData.data = data;
            md5ThreadData.Start(md5PktData);
            ripemd160PktData.data = data;
            ripemd160ThreadData.Start(ripemd160PktData);
            sha1PktData.data = data;
            sha1ThreadData.Start(sha1PktData);
            sha256PktData.data = data;
            sha256ThreadData.Start(sha256PktData);
            sha384PktData.data = data;
            sha384ThreadData.Start(sha384PktData);
            sha512PktData.data = data;
            sha512ThreadData.Start(sha512PktData);
            spamsumPktData.data = data;
            spamsumThreadData.Start(spamsumPktData);

            while (adlerThreadData.IsAlive || crc16ThreadData.IsAlive || crc32ThreadData.IsAlive ||
                   crc64ThreadData.IsAlive || md5ThreadData.IsAlive || ripemd160ThreadData.IsAlive ||
                   sha1ThreadData.IsAlive || sha256ThreadData.IsAlive || sha384ThreadData.IsAlive ||
                   sha512ThreadData.IsAlive || spamsumThreadData.IsAlive)
            {
            }

            List <ChecksumType> dataChecksums = new List <ChecksumType>();

            ChecksumType chk = new ChecksumType {
                type = ChecksumTypeType.adler32, Value = adler32ctxData.End()
            };

            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc16, Value = crc16ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc32, Value = crc32ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc64, Value = crc64ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.md5, Value = md5ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.ripemd160, Value = ripemd160ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha1, Value = sha1ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha256, Value = sha256ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha384, Value = sha384ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha512, Value = sha512ctxData.End()
            };
            dataChecksums.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.spamsum, Value = ssctxData.End()
            };
            dataChecksums.Add(chk);

            return(dataChecksums);
        }
Exemple #4
0
        internal List <ChecksumType> End()
        {
            List <ChecksumType> chks = new List <ChecksumType>();

            ChecksumType chk = new ChecksumType {
                type = ChecksumTypeType.adler32, Value = adler32ctx.End()
            };

            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc16, Value = crc16ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc32, Value = crc32ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.crc64, Value = crc64ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.md5, Value = md5ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.ripemd160, Value = ripemd160ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha1, Value = sha1ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha256, Value = sha256ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha384, Value = sha384ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.sha512, Value = sha512ctx.End()
            };
            chks.Add(chk);

            chk = new ChecksumType {
                type = ChecksumTypeType.spamsum, Value = ssctx.End()
            };
            chks.Add(chk);

            return(chks);
        }