Skip to content

Commit

Permalink
Patch initial encoding of encrypted value
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksagona committed Mar 7, 2024
1 parent cf395a8 commit 414d6d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Record/Encoded.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public function encodeValue(string $key, mixed $value): string
if (empty($this->cipherMethod) || empty($this->key) || empty($this->iv)) {
throw new Exception('Error: The encryption properties have not been set for this class.');
}
if (!(is_string($value) && ($this->decodeValue($key, $value) !== false))) {
$decodedValue = $this->decodeValue($key, $value);
if (!(is_string($value) && ($decodedValue !== false) && ($decodedValue != $value))) {
$value = base64_encode(
openssl_encrypt($value, $this->cipherMethod, $this->key, OPENSSL_RAW_DATA, base64_decode($this->iv))
);
Expand Down Expand Up @@ -312,4 +313,4 @@ public function __get(string $name): mixed
return $value;
}

}
}

0 comments on commit 414d6d2

Please sign in to comment.