Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Encrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ public function output(?string $filePath = null)
$encryptionInfoBuffer = EncryptionInfoBuilder::build($encryptionInfo);

$OLE = new OLE_PPS_File(OLE::Asc2Ucs('EncryptionInfo'));
if ($this->tmpPathFolder) {
$OLE->setTempDir($this->tmpPathFolder);
}
$OLE->init();
$OLE->append(pack('C*', ...$encryptionInfoBuffer));

$OLE2 = new OLE_PPS_File(OLE::Asc2Ucs('EncryptedPackage'));
if ($this->tmpPathFolder) {
$OLE2->setTempDir($this->tmpPathFolder);
}
$OLE2->init();
$filesize = filesize($encryptedPackage['tmpFile']);
for ($i = 0; $i < ($filesize / 4096); $i++) {
Expand Down
2 changes: 1 addition & 1 deletion tests/EncryptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function test_encryptor_with_binary_data()

public function test_encryptor_with_set_temp_path_folder()
{
(new Encrypt)->input('Book1.xlsx')->setTempPathFolder('/tmp')->password('111')->output('bb.xlsx');
(new Encrypt)->input('Book1.xlsx')->setTempPathFolder(dirname(__DIR__).DIRECTORY_SEPARATOR.'tmp')->password('111')->output('bb.xlsx');
$this->assertFileExists('bb.xlsx');
}
}
2 changes: 2 additions & 0 deletions tmp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore