예제 #1
0
 public SkeinConfig(Skein sourceHash)
 {
     stateSize   = sourceHash.StateSize;
     ConfigValue = new ulong[sourceHash.StateSize / 8];
     // Set the state size for the configuration
     ConfigString    = new ulong[ConfigValue.Length];
     ConfigString[1] = (ulong)sourceHash.HashSize;
 }
예제 #2
0
        public SkeinConfig(Skein sourceHash)
        {
            _stateSize = sourceHash.StateSize;

            // Allocate config value
            ConfigValue = new ulong[sourceHash.StateSize / 8];

            // Set the state size for the configuration
            ConfigString = new ulong[ConfigValue.Length];
            ConfigString[1] = (ulong) sourceHash.HashSize;
        }
예제 #3
0
 public SkeinTesting(Skein sourceHash)
 {
     _sourceHash = sourceHash;
 }
예제 #4
0
        private static void Go()
        {
            Random threadRand;
            lock (initRand) {
                threadRand = new Random(initRand.Next());
            }

            var skein = new Skein(1024, 1024);
            // Warm it up - for some reason you the first one it does is always wrong.
            skein.ComputeHash(new byte[] {0x1, 0x3, 0x4});

            var wc = new WebClient();

            var bytes = new byte[24];

            for (int threadRound = 0; ; threadRound++) {
                // Make a random caps 24 long string
                threadRand.NextBytes(bytes);
                for (int i = 0; i < bytes.Length; i++) {
                    bytes[i] = (byte) ('A' + bytes[i]%26);
                }
                var hash = skein.ComputeHash(bytes);
                var bitsDiff = BitsDiff(new BitArray(hash));

                if (bitsDiff < best)
                {
                    lock (bestLock)
                    {
                        best = bitsDiff;
                    }

                    int attempts = 0;
                    while (attempts < 5)
                    {
                        try
                        {
                            var nvc = new NameValueCollection();
                            nvc.Add("hashable", Encoding.ASCII.GetString(bytes));
                            var result = wc.UploadValues(url, "POST", nvc);
                            Console.WriteLine(Encoding.UTF8.GetString(result));
                            break;
                        }
                        catch (WebException)
                        {
                            attempts++;
                        }
                    }
                }

                if (threadRound == 65536) {
                    Console.WriteLine("Trying {0} - {1} (lowest: {2}, attempt: {3}, speed: {4} kH/s)", Encoding.ASCII.GetString(bytes), bitsDiff, best, round, speed);
                    Interlocked.Add(ref round, threadRound);
                    threadRound = 0;

                    lock (timeRunning) {
                        if (timeRunning.Elapsed.TotalSeconds > 1) {
                            speed = Math.Round((round - lastRound) / timeRunning.Elapsed.TotalSeconds / 1000.0, 2);
                            timeRunning.Restart();
                            lastRound = round;
                        }
                    }
                }
            }
        }
예제 #5
0
 public SkeinTesting(Skein sourceHash)
 {
     _sourceHash = sourceHash;
 }