Skip to content

Commit 18aab05

Browse files
authored
Use random_bytes function to generate mask (#22)
1 parent f4da401 commit 18aab05

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

src/Frame/HybiFrame.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,7 @@ public function encode(string $payload, int $type = Protocol::TYPE_TEXT, bool $m
133133
*/
134134
protected function generateMask()
135135
{
136-
if (\extension_loaded('openssl')) {
137-
return \openssl_random_pseudo_bytes(4);
138-
} else {
139-
// SHA1 is 128 bit (= 16 bytes)
140-
// So we pack it into 32 bits
141-
return \pack('N', \sha1(\spl_object_hash($this).\mt_rand(0, \PHP_INT_MAX).\uniqid('', true), true));
142-
}
136+
return \random_bytes(4);
143137
}
144138

145139
/**

0 commit comments

Comments
 (0)