Allow chaining of key set functions for encryption

This commit is contained in:
Clemens Schwaighofer
2024-12-20 15:13:22 +09:00
parent 7f9a4dc04f
commit 7248906da7
2 changed files with 6 additions and 3 deletions

View File

@@ -215,7 +215,7 @@ class SymmetricEncryption
public function setKey(
#[\SensitiveParameter]
string $key
) {
): SymmetricEncryption {
if (empty($key)) {
throw new \UnexpectedValueException('Key cannot be empty');
}
@@ -224,6 +224,7 @@ class SymmetricEncryption
// set key
$this->key = $key;
sodium_memzero($key);
return $this;
}
/**