-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdigest_custom_params.phpt
More file actions
52 lines (47 loc) · 1.21 KB
/
digest_custom_params.phpt
File metadata and controls
52 lines (47 loc) · 1.21 KB
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
46
47
48
49
50
51
52
--TEST--
Digest constructor with custom parameters test
--EXTENSIONS--
crc_fast
--FILE--
<?php
// Test Digest constructor with custom parameters that match CRC-32/ISO-HDLC
$params = new CrcFast\Params(
width: 32,
poly: 0x04C11DB7,
init: 0xFFFFFFFF,
refin: true,
refout: true,
xorout: 0xFFFFFFFF,
check: 0xCBF43926
);
// Test with predefined algorithm
$digest1 = new CrcFast\Digest(CrcFast\CRC_32_ISO_HDLC);
$digest1->update("123456789");
$result1 = $digest1->finalize();
// Test with custom parameters
$digest2 = new CrcFast\Digest($params);
$digest2->update("123456789");
$result2 = $digest2->finalize();
// Results should match
var_dump($result1 === $result2);
var_dump($result1);
var_dump($result2);
// Test binary output with custom parameters
$digest3 = new CrcFast\Digest($params);
$digest3->update("123456789");
$result3 = $digest3->finalize(true);
var_dump(strlen($result3));
var_dump(bin2hex($result3));
// Test finalizeReset with custom parameters
$digest4 = new CrcFast\Digest($params);
$digest4->update("123456789");
$result4 = $digest4->finalizeReset();
var_dump($result4);
?>
--EXPECT--
bool(true)
string(8) "cbf43926"
string(8) "cbf43926"
int(4)
string(8) "cbf43926"
string(8) "cbf43926"