コード例 #1
0
        public static Guid GenerateGuids(IEnumerable <ZipArchiveEntry> entries)
        {
            var stream = new MemoryStream();

            foreach (var entry in entries.OrderBy(x => x.Name, StringComparer.Ordinal))
            {
                stream.Write(BitConverter.GetBytes(entry.CompressedLength), 0, 8);
                stream.Write(BitConverter.GetBytes(entry.Length), 0, 8);
                stream.Write(BitConverter.GetBytes(GetChecksum(entry)), 0, 4);
            }

            stream.Position = 0;
            return(new Guid(HashBuilder.ComputeHash(stream)));
        }
コード例 #2
0
        private void UpdateTriangulationHash()
        {
            using (var md5 = HashBuilder.CreateHashAlgorithm())
            {
                foreach (var mesh in Meshes)
                {
                    var indices = mesh.GetTriangleIndices();
                    var block   = new byte[indices.Length * sizeof(int)];
                    Buffer.BlockCopy(indices, 0, block, 0, block.Length);

                    md5.TransformBlock(block, 0, block.Length, block, 0);
                }
                md5.TransformFinalBlock(new byte[0], 0, 0);
                Metadata.TriangulationHash = new Guid(md5.Hash);
            }
        }