namespace eval bloomfilter {}
# Tcl 8.5 is needed since we're using bignum
package require Tcl 8.5
proc bloomfilter::generateHashes {algorithm m k data} {
package require $algorithm
set rc 0
set bitlist {}
set key 0
while {[incr k -1] >= 0} {
if {[llength $bitlist] == 0} {
binary scan [${algorithm}::hmac -key [incr key] $data] I* bitlist
}
set bit [expr {[lindex $bitlist 0] % $m}]
set bitlist [lrange $bitlist 1 end]
set rc [expr {$rc | (2<<$bit)}]
}
return $rc
}

proc bloomfilter::init {algorithm n {m ""} {k ""}} {
set name "::bloomfilter::set[incr ::bloomfilter::setCounter]"
if {$m == ""} {
set m [expr {int($n * 9.6)}]
}
if {$k == ""} {
set k [expr {int(log(2) * ($m / $n))}]
}
upvar #0 $name v
set v(value) 0
set v(algorithm) $algorithm
set v(n) $n
set v(m) $m
set v(k) $k
return $name
}
proc bloomfilter::finalize {n} {
unset $n
}

proc bloomfilter::add {name data} {
upvar #0 $name v
set v(value) [expr {$v(value) | [generateHashes $v(algorithm) $v(m) $v(k) $data]}]
}
proc bloomfilter::query {name data} {
upvar #0 $name v
set hashes [generateHashes $v(algorithm) $v(m) $v(k) $data]
return [expr {($v(value) & $hashes) == $hashes}]
}

set n [bloomfilter::init 5]
bloomfilter::add $n "test1"
bloomfilter::add $n "test2"
bloomfilter::add $n "test3"
bloomfilter::add $n "test5"
bloomfilter::add $n "test7"
puts [bloomfilter::query $n "test1"]
puts [bloomfilter::query $n "test2"]
puts [bloomfilter::query $n "test3"]
puts [bloomfilter::query $n "test4"]
puts [bloomfilter::query $n "test5"]
puts [bloomfilter::query $n "test6"]
puts [bloomfilter::query $n "test7"]
bloomfilter::finalize $n

Most probably example above would return 1,1,1,0,1,0,1 lines.