Esempio n. 1
0
        public void Generate()
        {
            var buffer = new byte[Size];

            for (int i = 0; i < _count; i++)
            {
                _rand.NextBytes(buffer);

                var hash = Md5Util.GetMd5Hash(buffer);
                var path = $@"{_path}\test_{_start + i:D8}.{hash}.bin";
                Console.WriteLine($"{path}");
                File.WriteAllBytes(path, buffer);
            }
        }
Esempio n. 2
0
        public void Check()
        {
            Console.WriteLine($"Checking {_path} ..");
            var files = Directory.GetFiles(_path, "*.bin", SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                var buffer = File.ReadAllBytes(file);
                var hash   = Md5Util.GetMd5Hash(buffer);

                var shortFile = Path.GetFileName(file);
                var tokens    = shortFile.Split('.');

                if (tokens[1] != hash)
                {
                    Console.WriteLine($"Error: {shortFile} {hash}");
                }
                else
                {
                    Console.Write(".");
                }
            }
            Console.WriteLine();
        }