Example #1
0
    public static int Main()
    {
        var hashes = new IStringHash[] { new StandardHash (),
                     new MurmurHash2Simple (),
                     new SuperFastHashSimple (),
                     /*
                     new CryptographicHash (MD5.Create ()),
                     new CryptographicHash (SHA1.Create ()),
                     new CryptographicHash (RIPEMD160Managed.Create ()),
                     new CryptographicHash (MACTripleDES.Create ())
                     */ };
        var bloom = new BloomFilter (1000003, hashes);
        var positive = new List<string> ();
        var negative = new List<string> ();
        var toggle = true;
        foreach (var line in File.ReadAllLines ("/usr/share/dict/words"))
        {
        var l = line.Trim ();
        if (toggle)
        {
        positive.Add (l);
        bloom.Add (l);
        }
        else
        {
        negative.Add (l);
        }
        toggle = !toggle;
        }

        Console.WriteLine ("occupancy for " + positive.Count + " words: " + bloom.Occupancy ());

        foreach (var line in positive)
        {
        if (!bloom.Lookup (line))
        {
        Console.WriteLine ("error!");
        return 1;
        }
        }

        int false_positives = 0;
        foreach (var line in negative)
        {
        if (bloom.Lookup (line))
        ++false_positives;
        }

        Console.WriteLine ("false positives: " + ((float)false_positives / negative.Count));

        return 0;
    }
 public UserController(
     IUserManagement UserManagement,
     IMiddleManagement MiddleManagment,
     IUserSession UserSession,
     IUserAuthentication UserAuthentication,
     IEnumerable<IUserAuthenticator> UserAuthenticators,
     IFormsAuthentication FormsAuthentication,
     IStringHash StringHash)
     : base(MiddleManagment, UserSession, FormsAuthentication)
 {
     userManagement = UserManagement;
     userAuthentication = UserAuthentication;
     userAuthenticators = UserAuthenticators;
     formsAuthentication = FormsAuthentication;
     stringHash = StringHash;
 }
 public WebsiteFactory(IStringHash stringHash)
 {
     _stringHash = stringHash;
 }