Пример #1
0
 static BasicFilter FilterLoadSha512(List<string> words, ushort hashNumber)
 {
     var watch = new Stopwatch();
     BasicFilter filter = new BasicFilter(FilterWidth, HashFunc.SHA512, hashNumber);
     watch.Start();
     foreach (string w in words)
         filter.Insert(w);
     watch.Stop();
     Console.WriteLine($"SHA512 ({hashNumber} times): {(double)watch.ElapsedMilliseconds / 1000} sec");
     return filter;
 }
Пример #2
0
        public void Murmur3FilterCheck()
        {
            BasicFilter filter = new BasicFilter(50, HashFunc.Murmur3);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere5").Presence == BloomPresence.NotInserted);
        }
Пример #3
0
        public void SHA512FilterCheck()
        {
            BasicFilter filter = new BasicFilter(50, HashFunc.SHA512);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere4").Presence == BloomPresence.NotInserted);

            // This was brute-forced to have matching bits although it's not in the set
            Assert.True(filter.Check("notInThere11").Presence == BloomPresence.MightBeInserted);
        }
Пример #4
0
        public void BasicFilterWithPrecalculatedProb()
        {
            BasicFilter filter = new BasicFilter(40000, 1.0E-7);

            foreach (string str in WordList)
            {
                filter.Insert(str);
            }

            foreach (string str in WordList)
            {
                Assert.True(filter.Check(str).Presence == BloomPresence.MightBeInserted);
            }

            // This was brute-forced not to be in the set
            Assert.True(filter.Check("notInThere4").Presence == BloomPresence.NotInserted);

            // This is inside the set
            FilterResult res = filter.Check("radioimmunoelectrophoresis");

            Assert.True(res.Presence == BloomPresence.MightBeInserted);
            Assert.True(res.Probability <= 1.0E-7);
        }