-
Notifications
You must be signed in to change notification settings - Fork 297
/
pdqhashtest.php
46 lines (38 loc) · 1002 Bytes
/
pdqhashtest.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
44
45
<?php
// ================================================================
// Copyright (c) Meta Platforms, Inc. and affiliates.
// ================================================================
require 'pdqhash.php';
if (count($argv) > 1) {
fprintf(STDERR, "%s: takes no arguments.\n", $argv[0]);
exit(1);
}
$hash = PDQHash::makeZeroesHash();
$s = $hash->toHexString();
echo "s=$s\n";
for ($i = 0; $i < 256; $i++) {
$hash->setBit($i);
$s = $hash->toHexString();
$n = $hash->hammingNorm();
echo "s=$s n=$n\n";
}
$s = 'f8f8f0cce0f4e84d0e370a22028f67f0b36e2ed596623e1d33e6339c4e9c9b22';
echo "s=$s\n";
$hash = PDQHash::fromHexString($s);
$s = $hash->toHexString();
echo "s=$s\n";
$strings = $hash->to16BitStrings();
echo "\n";
foreach ($strings as $string) {
echo "$string\n";
}
$strings = $hash->to32BitStrings();
echo "\n";
foreach ($strings as $string) {
echo "$string\n";
}
$strings = $hash->to64BitStrings();
echo "\n";
foreach ($strings as $string) {
echo "$string\n";
}