Skip to content

Commit e11a702

Browse files
authored
ext/hash: tests for md5 and sha1 compatibility (#18525)
Add test cases to check compatibility between the `hash("algo")` and `md5()`/`sha1()` functions.
1 parent 73c4e9f commit e11a702

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

ext/hash/tests/md5.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ echo hash('md5', '') . "\n";
66
echo hash('md5', 'a') . "\n";
77
echo hash('md5', '012345678901234567890123456789012345678901234567890123456789') . "\n";
88
echo hash('md5', str_repeat('a', 1000000)) . "\n";
9+
var_dump(hash('md5', 'string') === md5('string'));
910
?>
1011
--EXPECT--
1112
d41d8cd98f00b204e9800998ecf8427e
1213
0cc175b9c0f1b6a831c399e269772661
1314
1ced811af47ead374872fcca9d73dd71
1415
7707d6ae4e027c70eea2a935c2296f21
16+
bool(true)

ext/hash/tests/sha1.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ echo hash('sha1', '012345678901234567890123456789012345678901234567890123456789'
1010
echo hash('sha1', 'abc') . "\n";
1111
echo hash('sha1', 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') . "\n";
1212
echo hash('sha1', str_repeat('a', 1000000)) . "\n";
13+
var_dump(hash('sha1', 'string') === sha1('string')) . "\n";
1314
?>
1415
--EXPECT--
1516
da39a3ee5e6b4b0d3255bfef95601890afd80709
@@ -18,3 +19,4 @@ f52e3c2732de7bea28f216d877d78dae1aa1ac6a
1819
a9993e364706816aba3e25717850c26c9cd0d89d
1920
84983e441c3bd26ebaae4aa1f95129e5e54670f1
2021
34aa973cd4c4daa4f61eeb2bdbad27316534016f
22+
bool(true)

0 commit comments

Comments
 (0)