Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nathankrishnan/46f4c640c59ddee7de6dd1aacd4db1c8 to your computer and use it in GitHub Desktop.
Save nathankrishnan/46f4c640c59ddee7de6dd1aacd4db1c8 to your computer and use it in GitHub Desktop.
let badDomains = BloomFilter<String>(size: 1024, hashFunctions: [djb2, sdbm])
badDomains.insert("badguys.com")
badDomains.insert("drevil.me")
badDomains.insert("virus.io")
let websiteToLoad = NSURL(string: "http://virus.io")
if let validDomain = websiteToLoad?.host {
if badDomains.query(validDomain) {
print("The website is most likely bad!")
} else {
print("This website doesn't exist in our dossier. Let's proceed.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment