-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.php
44 lines (32 loc) · 1.04 KB
/
generate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
ini_set('memory_limit', '2G');
require_once __DIR__."/Bloomer.class.php";
$passwordFiles = glob(__DIR__."/lists/*.txt");
$bloomer = new Bloomer(array(
'unique' => 0
));
array_shift($argv);
// For debugging purposes any other arguments passed to the generate.php script
// are added to the filter and their hash bits are displayed to STDOUT (this makes
// debugging easier)
foreach ($argv as $arg) {
$bit = $bloomer->addHash(md5($arg));
echo "$arg = $bit\n";
$bit = $bloomer->addHash(sha1($arg));
echo "$arg = $bit\n";
$bit = $bloomer->addHash(hash('sha256', $arg));
echo "$arg = $bit\n";
}
foreach ($passwordFiles as $file) {
echo "Adding passwords from $file\n";
$bloomer->addPasswordFile($file);
}
$elementCount = number_format($bloomer->getElementCount());
$errorRate = $bloomer->getErrorRate();
$hex = $bloomer->getHex();
file_put_contents(__DIR__."/bloom.hex", $hex);
echo "-------------------------\n";
echo "Unique Passwords: $elementCount\n";
echo "Estimated Error: $errorRate\n";
echo "Written to file bloom.hex\n";
echo "\n";