fix(crypto): guard decryptHex against malformed hex input

This commit is contained in:
kj
2026-11-22 13:25:48 -03:00
parent 16e5dd2200
commit 5a28e37998
+4
View File
@@ -41,6 +41,10 @@ class Crypto
*/ */
public static function decryptHex(string $data, string $password = PRIVATE_KEY): string public static function decryptHex(string $data, string $password = PRIVATE_KEY): string
{ {
if ($data === '' || !ctype_xdigit($data) || strlen($data) % 2 !== 0) {
return '';
}
return static::decrypt(hex2bin($data), $password); return static::decrypt(hex2bin($data), $password);
} }