Fix phpstan problems in test db encryption file
This commit is contained in:
@@ -136,33 +136,31 @@ if ($res === false) {
|
|||||||
if (hash_equals($string_hmac, $res['pg_hmac_text'])) {
|
if (hash_equals($string_hmac, $res['pg_hmac_text'])) {
|
||||||
print "libsodium and pgcrypto hash hmac match<br>";
|
print "libsodium and pgcrypto hash hmac match<br>";
|
||||||
}
|
}
|
||||||
}
|
// do compare for PHP and pgcrypto settings
|
||||||
$encryptedMessage_template = <<<TEXT
|
$encryptedMessage_template = <<<TEXT
|
||||||
-----BEGIN PGP MESSAGE-----
|
-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
{BASE64}
|
{BASE64}
|
||||||
-----END PGP MESSAGE-----
|
-----END PGP MESSAGE-----
|
||||||
TEXT;
|
TEXT;
|
||||||
$base64_string = base64_encode(hex2bin($res['pg_crypt_text']));
|
$base64_string = base64_encode(hex2bin($res['pg_crypt_text']) ?: '');
|
||||||
$encryptedMessage = str_replace(
|
$encryptedMessage = str_replace(
|
||||||
'{BASE64}',
|
'{BASE64}',
|
||||||
$base64_string,
|
$base64_string,
|
||||||
$encryptedMessage_template
|
$encryptedMessage_template
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$literalMessage = OpenPGP::decryptMessage($encryptedMessage, passwords: [$key]);
|
$literalMessage = OpenPGP::decryptMessage($encryptedMessage, passwords: [$key]);
|
||||||
$decrypted = $literalMessage->getLiteralData()->getData();
|
$decrypted = $literalMessage->getLiteralData()->getData();
|
||||||
print "Pg decrypted PHP: " . $decrypted . "<br>";
|
print "Pg decrypted PHP: " . $decrypted . "<br>";
|
||||||
if ($decrypted == $text_string) {
|
if ($decrypted == $text_string) {
|
||||||
print "Decryption worked<br>";
|
print "Decryption worked<br>";
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
print "Error decrypting message: " . $e->getMessage() . "<br>";
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
|
||||||
print "Error decrypting message: " . $e->getMessage() . "<br>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// do compare for PHP and pgcrypto settings
|
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
Reference in New Issue
Block a user