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 "