diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index c2fbc812..30146532 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1363,7 +1363,7 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, $partS $partStructure_id = ($partStructure->ifid && isset($partStructure->id)) ? $partStructure->id : null; $attachment = new IncomingMailAttachment(); - $attachment->id = \bin2hex(\random_bytes(20)); + $attachment->id = \bin2hex(\rand(10000000000000000000,99999999999999999999)); $attachment->contentId = isset($partStructure_id) ? \trim($partStructure_id, ' <>') : null; $attachment->name = $fileName; $attachment->disposition = (isset($partStructure->disposition) && \is_string($partStructure->disposition)) ? $partStructure->disposition : null; @@ -1382,7 +1382,7 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, $partS $attachmentsDir = $this->getAttachmentsDir(); if (null != $attachmentsDir) { - $fileSysName = \bin2hex(\random_bytes(16)).'.bin'; + $fileSysName = \bin2hex(\rand(1000000000000000,9999999999999999)).'.bin'; $filePath = $attachmentsDir.DIRECTORY_SEPARATOR.$fileSysName; if (\strlen($filePath) > 255) { diff --git a/tests/unit/LiveMailboxTest.php b/tests/unit/LiveMailboxTest.php index 5fb6486b..d0234172 100644 --- a/tests/unit/LiveMailboxTest.php +++ b/tests/unit/LiveMailboxTest.php @@ -178,7 +178,7 @@ public function testGetImapStream(HiddenString $imapPath, HiddenString $login, H */ public function ComposeProvider() { - $random_subject = 'test: '.\bin2hex(\random_bytes(16)); + $random_subject = 'test: '.\bin2hex(\rand(1000000000000000,9999999999999999)); yield [ ['subject' => $random_subject], @@ -197,7 +197,7 @@ public function ComposeProvider() ), ]; - $random_subject = 'barbushin/php-imap#448: dot first:'.\bin2hex(\random_bytes(16)); + $random_subject = 'barbushin/php-imap#448: dot first:'.\bin2hex(\rand(1000000000000000,9999999999999999)); yield [ ['subject' => $random_subject], @@ -229,7 +229,7 @@ public function ComposeProvider() ), ]; - $random_subject = 'barbushin/php-imap#448: dot last: '.\bin2hex(\random_bytes(16)); + $random_subject = 'barbushin/php-imap#448: dot last: '.\bin2hex(\rand(1000000000000000,9999999999999999)); yield [ ['subject' => $random_subject], @@ -261,10 +261,10 @@ public function ComposeProvider() ), ]; - $random_subject = 'barbushin/php-imap#391: '.\bin2hex(\random_bytes(16)); + $random_subject = 'barbushin/php-imap#391: '.\bin2hex(\rand(1000000000000000,9999999999999999)); - $random_attachment_a = \base64_encode(\random_bytes(16)); - $random_attachment_b = \base64_encode(\random_bytes(16)); + $random_attachment_a = \base64_encode(\rand(1000000000000000,9999999999999999)); + $random_attachment_b = \base64_encode(\rand(1000000000000000,9999999999999999)); yield [ ['subject' => $random_subject],