From a66cc09095f950fa4b384c75f2da37addce6f4c8 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 15 Apr 2025 17:46:41 +0900 Subject: [PATCH] Fix phpstan problems in test db encryption file --- www/admin/class_test.db.encryption.php | 44 ++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/www/admin/class_test.db.encryption.php b/www/admin/class_test.db.encryption.php index 1287dd49..6b5c6ed7 100644 --- a/www/admin/class_test.db.encryption.php +++ b/www/admin/class_test.db.encryption.php @@ -136,33 +136,31 @@ if ($res === false) { if (hash_equals($string_hmac, $res['pg_hmac_text'])) { print "libsodium and pgcrypto hash hmac match
"; } -} -$encryptedMessage_template = <<getLiteralData()->getData(); - print "Pg decrypted PHP: " . $decrypted . "
"; - if ($decrypted == $text_string) { - print "Decryption worked
"; + {BASE64} + -----END PGP MESSAGE----- + TEXT; + $base64_string = base64_encode(hex2bin($res['pg_crypt_text']) ?: ''); + $encryptedMessage = str_replace( + '{BASE64}', + $base64_string, + $encryptedMessage_template + ); + try { + $literalMessage = OpenPGP::decryptMessage($encryptedMessage, passwords: [$key]); + $decrypted = $literalMessage->getLiteralData()->getData(); + print "Pg decrypted PHP: " . $decrypted . "
"; + if ($decrypted == $text_string) { + print "Decryption worked
"; + } + } catch (\Exception $e) { + print "Error decrypting message: " . $e->getMessage() . "
"; } -} catch (\Exception $e) { - print "Error decrypting message: " . $e->getMessage() . "
"; } - -// do compare for PHP and pgcrypto settings - print ""; // __END__