Skip to content
Merged
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
7 changes: 5 additions & 2 deletions src/FileEncryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public function __construct(
private string $filename,
#[SensitiveParameter] private string $secret
) {
if (!file_exists($this->filename)) {
throw new FileEncryptorException("File not found");
}
}

/**
Expand All @@ -26,7 +29,7 @@ public function encryptFile(): bool
$plainText = file_get_contents($this->filename);

if (!$plainText) {
throw new FileEncryptorException('File not found or has no content');
throw new FileEncryptorException('File has no content');
}
if (ctype_xdigit($plainText)) {
throw new FileEncryptorException('file is already encrypted');
Expand Down Expand Up @@ -65,7 +68,7 @@ public function decryptFile(): bool
$encryptedData = file_get_contents($this->filename);

if (!$encryptedData) {
throw new FileEncryptorException('File not found or has no content');
throw new FileEncryptorException('File has no content');
}

if (!ctype_xdigit($encryptedData)) {
Expand Down