New Secruity namespace added

Move Passwords from Check to Security and deprecate old

Add new SymmetricEncryption and CreateKey

CreateKey class just creates keys for the SymmetricEncryption
SymmetricEncryption uses the hex2bin calls to convert the hex key to the
internal binary key

Example:
$key = CreateKey::generateRandomKey();
$encrypted = SymmetricEncryption::encrypt($string, $key);
$decrypted = SymmetricEncryption::decrypt($encrypted, $key);

Above $key must be stored in some secure location (.env file)
This commit is contained in:
Clemens Schwaighofer
2023-05-24 15:47:02 +09:00
parent 0250b86b3f
commit ac037eabde
16 changed files with 548 additions and 34 deletions

View File

@@ -20,10 +20,10 @@ define('USE_DATABASE', false);
// sample config
require 'config.php';
// define log file id
$LOG_FILE_ID = 'classTest-pass';
$LOG_FILE_ID = 'classTest-password';
ob_end_flush();
use CoreLibs\Check\Password as PwdChk;
use CoreLibs\Security\Password as PwdChk;
$log = new CoreLibs\Debug\Logging([
'log_folder' => BASE . LOG,
@@ -35,8 +35,8 @@ $log = new CoreLibs\Debug\Logging([
'echo_all' => $ECHO_ALL ?? false,
'print_all' => $PRINT_ALL,
]);
$_password = new CoreLibs\Check\Password();
$password_class = 'CoreLibs\Check\Password';
$_password = new CoreLibs\Security\Password();
$password_class = 'CoreLibs\Security\Password';
// define a list of from to color sets for conversion test