private void Test()
        {
            _state = new BruteforceState("program.state");
            var             resultLog       = new FileResultLog("results.txt");
            HashBruteforcer hashBruteforcer = new HashBruteforcer(_passportHashes, 8, _state, resultLog);

            hashBruteforcer.Wait();

            resultLog.Dispose();

            using var streamReader = File.OpenText("results.txt");
            Dictionary <int, int> counters = new Dictionary <int, int>();

            while (!streamReader.EndOfStream)
            {
                ReadOnlySpan <char> line = streamReader.ReadLine();
                var series = line.Slice(0, 4);
                if (int.TryParse(series, out var intSeries))
                {
                    if (!counters.TryGetValue(intSeries, out int counter))
                    {
                        counters.Add(intSeries, 1);
                    }
                    else
                    {
                        counters[intSeries] = counter + 1;
                    }
                }
            }
            var lineSeries = new OxyPlot.Series.LineSeries()
            {
                CanTrackerInterpolatePoints = false
            };

            for (int i = 0; i < 10000; i++)
            {
                if (counters.TryGetValue(i, out var count))
                {
                    lineSeries.Points.Add(new OxyPlot.DataPoint(i, count));
                }
                else
                {
                    lineSeries.Points.Add(new OxyPlot.DataPoint(i, 0));
                }
            }

            _plotModel.Series.Add(lineSeries);

            foreach (var axis in _plotModel.Axes)
            {
                axis.AbsoluteMinimum = 0;
                axis.Minimum         = 0;
            }

            _plotModel.InvalidatePlot(true);
        }
Esempio n. 2
0
        private void Test()
        {
            _state = new BruteforceState("program.state");
            var             resultLog       = new FileResultLog("results.txt");
            HashBruteforcer hashBruteforcer = new HashBruteforcer(_passportHashes, 8, _state, resultLog);

            hashBruteforcer.Wait();

            resultLog.Dispose();

            using var streamReader = File.OpenText("results.txt");
            Dictionary <int, int> counters = new Dictionary <int, int>();

            while (!streamReader.EndOfStream)
            {
                ReadOnlySpan <char> line = streamReader.ReadLine();
                var series = line.Slice(0, 4);
                if (int.TryParse(series, out var intSeries))
                {
                    if (!counters.TryGetValue(intSeries, out int counter))
                    {
                        counters.Add(intSeries, 1);
                    }
                    else
                    {
                        counters[intSeries] = counter + 1;
                    }
                }
            }
            var lineSeries = new OxyPlot.Series.LineSeries()
            {
                CanTrackerInterpolatePoints = false
            };

            foreach (var pair in counters)
            {
                lineSeries.Points.Add(new OxyPlot.DataPoint(pair.Key, pair.Value));
            }
            lineSeries.Points.Sort((x, y) => Math.Sign(x.X - y.X));


            _plotModel.Series.Add(lineSeries);

            _plotModel.InvalidatePlot(true);
        }