Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a66cc09095 | ||
|
|
1cfdc45107 | ||
|
|
07e46c91ab |
@@ -15,6 +15,8 @@ ob_start();
|
|||||||
define('USE_DATABASE', true);
|
define('USE_DATABASE', true);
|
||||||
// sample config
|
// sample config
|
||||||
require 'config.php';
|
require 'config.php';
|
||||||
|
// for testing encryption compare
|
||||||
|
use OpenPGP\OpenPGP;
|
||||||
// define log file id
|
// define log file id
|
||||||
$LOG_FILE_ID = 'classTest-db-query-encryption';
|
$LOG_FILE_ID = 'classTest-db-query-encryption';
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
@@ -50,6 +52,7 @@ print "Secret Key: " . $key . "<br>";
|
|||||||
|
|
||||||
// test text
|
// test text
|
||||||
$text_string = "I a some deep secret";
|
$text_string = "I a some deep secret";
|
||||||
|
$text_string = "I a some deep secret ABC";
|
||||||
//
|
//
|
||||||
$crypt = new SymmetricEncryption($key);
|
$crypt = new SymmetricEncryption($key);
|
||||||
$encrypted = $crypt->encrypt($text_string);
|
$encrypted = $crypt->encrypt($text_string);
|
||||||
@@ -133,11 +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
|
||||||
|
-----BEGIN PGP MESSAGE-----
|
||||||
|
|
||||||
|
{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 . "<br>";
|
||||||
|
if ($decrypted == $text_string) {
|
||||||
|
print "Decryption worked<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__
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
"egrajp/smarty-extended": "^5.4",
|
"egrajp/smarty-extended": "^5.4",
|
||||||
"php": ">=8.1",
|
"php": ">=8.1",
|
||||||
"gullevek/dotenv": "^2.0",
|
"gullevek/dotenv": "^2.0",
|
||||||
"psr/log": "^2.0 || ^3.0"
|
"psr/log": "^2.0 || ^3.0",
|
||||||
|
"php-privacy/openpgp": "^2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1371,7 +1371,7 @@ class Generate
|
|||||||
) {
|
) {
|
||||||
$this->msg .= sprintf(
|
$this->msg .= sprintf(
|
||||||
$this->l->__('Please enter a valid (%s) input for the <b>%s</b> Field!<br>'),
|
$this->l->__('Please enter a valid (%s) input for the <b>%s</b> Field!<br>'),
|
||||||
$this->dba->getTableArray()[$key]['error_example'],
|
$this->dba->getTableArray()[$key]['error_example'] ?? '[MISSING]',
|
||||||
$this->dba->getTableArray()[$key]['output_name']
|
$this->dba->getTableArray()[$key]['output_name']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2602,7 +2602,7 @@ class Generate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add lost error ones
|
// add lost error ones
|
||||||
$this->log->error('P: ' . $data['prefix'] . ', '
|
$this->log->error('Prefix: ' . $data['prefix'] . ', '
|
||||||
. Support::prAr($_POST['ERROR'][$data['prefix']] ?? []));
|
. Support::prAr($_POST['ERROR'][$data['prefix']] ?? []));
|
||||||
if ($this->error && !empty($_POST['ERROR'][$data['prefix']])) {
|
if ($this->error && !empty($_POST['ERROR'][$data['prefix']])) {
|
||||||
$prfx = $data['prefix']; // short
|
$prfx = $data['prefix']; // short
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class EditUsers implements Interface\TableArraysInterface
|
|||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'error_check' => 'unique|custom',
|
'error_check' => 'unique|custom',
|
||||||
'error_regex' => "/^[A-Za-z0-9]+$/",
|
'error_regex' => "/^[A-Za-z0-9]+$/",
|
||||||
|
'error_example' => "ABCdef123",
|
||||||
'emptynull' => 1,'min_edit_acl' => '100',
|
'emptynull' => 1,'min_edit_acl' => '100',
|
||||||
'min_show_acl' => '100',
|
'min_show_acl' => '100',
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user