Skip to content

Commit

Permalink
use a sha256 instead of base64
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlmoon committed Sep 5, 2024
1 parent 2ae10b0 commit 2fd207d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/TmpDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public function tmpDir(?string $base_dir = null): string {

do {
$success = false;
$dir = $base_dir . '/' . base64_encode(random_bytes(32));
$dir = $base_dir . '/' . hash('sha256', (random_bytes(32)));
if (!file_exists($dir)) {
$success = mkdir($dir);
$success = mkdir($dir, recursive: true);
}
} while (!$success);

Expand Down
2 changes: 1 addition & 1 deletion tests/TmpDirTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testTmpDir() {

$dir2 = $this->tmpDir($dir);

$this->assertTrue(is_dir($dir));
$this->assertTrue(is_dir($dir2));

rmdir($dir2);
rmdir($dir);
Expand Down

0 comments on commit 2fd207d

Please sign in to comment.