Robert 3 years ago
parent 9b495f254f
commit 6b62e2255c
  1. 9
      src/configs/mockup/loadall.php
  2. 9
      src/configs/mockup/on_sessions.php
  3. 8
      src/mockup/controllers/app/cookie_ctrl.php
  4. 23
      src/mockup/controllers/app/enc_ctrl.php
  5. 29
      src/services/mockup/loadall.php
  6. 2
      src/services/mockup/on_html_filter.php
  7. 2
      src/services/mockup/on_log.php
  8. 16
      src/services/mockup/on_session_encryption.php
  9. 2
      src/services/mockup/on_templates.php
  10. 2
      src/services/mockup/on_test_db.php

@ -47,13 +47,12 @@
/* Contents of : on_sessions.php */ /* Contents of : on_sessions.php */
\main_tts\configure::set('sessions', array( \main_tts\configure::set('sessions', array(
'engine' => 'php', // php, db 'type' => 'cookies', // Session Type: php, files, redis, or cookies
'type' => 'none', // Session Type: files, database, or cache 'session_variable' => 'ses_app_', // set session variable name for project
'session_variable' => 'ses_app_aaa_', // set session variable name for project 'session_name' => 'main_SESS', // More secure then PHPSESSID
'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID
'session_table' => false, // DB PHP Session Table name, false = USE FILES 'session_table' => false, // DB PHP Session Table name, false = USE FILES
'session_security_level' => 'blaze', // Faster Reqests keep at: blaze 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze
'session_key' => '6cb0d56f2345917624f2c5473e4d32cd', 'session_key' => '78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2',
)); ));
/* Contents of : on_tts.php */ /* Contents of : on_tts.php */

@ -1,11 +1,10 @@
<?php <?php
\main_tts\configure::set('sessions', array( \main_tts\configure::set('sessions', array(
'engine' => 'php', // php, db 'type' => 'cookies', // Session Type: php, files, redis, or cookies
'type' => 'none', // Session Type: files, database, or cache 'session_variable' => 'ses_app_', // set session variable name for project
'session_variable' => 'ses_app_aaa_', // set session variable name for project 'session_name' => 'main_SESS', // More secure then PHPSESSID
'session_name' => 'aaa_sys_342_', // More secure then PHPSESSID
'session_table' => false, // DB PHP Session Table name, false = USE FILES 'session_table' => false, // DB PHP Session Table name, false = USE FILES
'session_security_level' => 'blaze', // Faster Reqests keep at: blaze 'session_security_level' => 'blaze', // Faster Reqests keep at: blaze
'session_key' => '6cb0d56f2345917624f2c5473e4d32cd', 'session_key' => '78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2',
)); ));

@ -17,13 +17,7 @@ namespace prj\mockup\controllers\app;
class cookie_ctrl { class cookie_ctrl {
public function __construct() { public function __construct() {
$key = "78a5011b9997cd03a28a3412c66565b7c32715b35e055d7abfc228236308d3b2"; \tts\session_management::start();
$sc = new \tts\services\paragon_crypto\sodium_storage($key);
$handler = new \tts\services\sessions\cookie_sessions($sc);
session_set_save_handler($handler, true);
session_start();
} }
public function save() { public function save() {

@ -12,6 +12,7 @@ namespace prj\mockup\controllers\app;
class enc_ctrl { class enc_ctrl {
public $page_output; public $page_output;
private $key = "51623a064210f9d3d5162d0885621f53";
private function get_roles(): string { private function get_roles(): string {
$roles = ['roles'=>'admin, super, rw', 'name'=>'Bob']; $roles = ['roles'=>'admin, super, rw', 'name'=>'Bob'];
@ -29,22 +30,21 @@ class enc_ctrl {
} }
private function time_enc(array $levels): void { private function time_enc(array $levels): void {
$enc = new \tts\services\encryption(); $enc = new \tts\services\encryption($this->key);
foreach($levels as $level) { foreach($levels as $level) {
echo "ENC: Level = $level <br>" . PHP_EOL; echo "ENC: Level = $level <br>" . PHP_EOL;
$enc->change_security_level($level); $enc->change_security_level($level);
// $key = $enc->generate_valid_key(); // $key = $enc->generate_valid_key();
$key = "51623a064210f9d3d5162d0885621f53"; echo "KEY Used: $this->key <br>" . PHP_EOL;
echo "KEY Used: $key <br>" . PHP_EOL;
$startTime = microtime(true); $startTime = microtime(true);
$data = $enc->encrypt($key, $this->get_roles()); $data = $enc->encrypt($this->get_roles());
echo "<br> $data <br>" . PHP_EOL; echo "<br> $data <br>" . PHP_EOL;
echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
$startTime = microtime(true); $startTime = microtime(true);
$decoded = $enc->decrypt($key, $data); $decoded = $enc->decrypt($data);
$this->show_roles($decoded); $this->show_roles($decoded);
echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
echo "<hr><br>".PHP_EOL; echo "<hr><br>".PHP_EOL;
@ -69,19 +69,20 @@ class enc_ctrl {
} }
public function sodium() { // 0.0041 Seconds public function sodium() { // 0.0041 Seconds
$crypto = new \tts\services\paragon_crypto\crypto();
// echo $crypto->a_single_key_maker();
$key = "oH5LUubQXkUgC2sXkxahLnzgcZokVFANyxAew+kOvuk="; $key = "oH5LUubQXkUgC2sXkxahLnzgcZokVFANyxAew+kOvuk=";
$crypto = new \tts\services\paragon_crypto\crypto($key);
// echo $crypto->a_single_key_maker();
$startTime = microtime(true); $startTime = microtime(true);
$data = $crypto->safe_encrypt($this->get_roles(), $key, $crypto::single_key); $data = $crypto->encrypt($this->get_roles());
echo "<br> $data <br>" . PHP_EOL; echo "<br> $data <br>" . PHP_EOL;
echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
// $data = "sJWIPEasG1W8ModZJKU8jOR78/i1qUZDl6nX5ew21ceOdEZHNDGwqCA1lD70GuIHP4DJEMQ="; // $data = "sJWIPEasG1W8ModZJKU8jOR78/i1qUZDl6nX5ew21ceOdEZHNDGwqCA1lD70GuIHP4DJEMQ=";
$startTime = microtime(true); $startTime = microtime(true);
$decoded = $crypto->safe_decrypt($data, $key, $crypto::single_key); $decoded = $crypto->decrypt($data);
$this->show_roles($decoded); $this->show_roles($decoded);
echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
@ -93,13 +94,13 @@ class enc_ctrl {
$sc = new \tts\services\paragon_crypto\sodium_storage($key); $sc = new \tts\services\paragon_crypto\sodium_storage($key);
$startTime = microtime(true); $startTime = microtime(true);
$encoded = $sc->encode("admin", $this->get_roles()); $encoded = $sc->encrypt($this->get_roles());
echo "<br> $encoded <br>" . PHP_EOL; echo "<br> $encoded <br>" . PHP_EOL;
echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Encrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";
try { try {
$startTime = microtime(true); $startTime = microtime(true);
$plain_text = $sc->decode("admin", $encoded); $plain_text = $sc->decrypt($encoded);
$this->show_roles($plain_text); $this->show_roles($plain_text);
echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n"; echo "Decrypt Time: " . number_format(( microtime(true) - $startTime), 4) . " Seconds\n";

@ -1,17 +1,18 @@
<?php <?php
declare(strict_types=1); declare(strict_types=1);
/*
/* * This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration!
* This file is Auto-Generated, Do NOT Modify!!! Please Delete this file to update configuration! */
*/
/* Contents of : on_html_filter.php */ /* Contents of : on_html_filter.php */
\main_tts\registry::get('di')->register('html_filter', function() { \main_tts\registry::get('di')->register('html_filter', function() {
return new \tts\services\html_filter(); return new \tts\services\html_filter();
}); });
/* Contents of : on_log.php */ /* Contents of : on_log.php */
\main_tts\registry::get('di')->register('log', function(array $arg) { \main_tts\registry::get('di')->register('log', function(array $arg) {
$file_name = null; $file_name = null;
if (isset($arg[0]) && is_string($arg[0])) { if (isset($arg[0]) && is_string($arg[0])) {
@ -29,6 +30,22 @@ declare(strict_types=1);
return new \tts\services\log(); return new \tts\services\log();
}); });
/* Contents of : on_session_encryption.php */
/**
* @author Robert Strutts <Robert@TryingToScale.com>
* @copyright Copyright (c) 2022, Robert Strutts.
* @license https://mit-license.org/
*/
\main_tts\registry::get('di')->register('session_encryption', function($args) {
try {
$key = \main_tts\configure::get('sessions', 'session_key');
return new \tts\services\paragon_crypto\sodium_storage($key);
} catch (\Exception $e) {
}
});
/* Contents of : on_templates.php */ /* Contents of : on_templates.php */
\main_tts\registry::get('di')->register('templates', function(array $arg) { \main_tts\registry::get('di')->register('templates', function(array $arg) {

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1);
\main_tts\registry::get('di')->register('html_filter', function() { \main_tts\registry::get('di')->register('html_filter', function() {
return new \tts\services\html_filter(); return new \tts\services\html_filter();
}); });

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1);
\main_tts\registry::get('di')->register('log', function(array $arg) { \main_tts\registry::get('di')->register('log', function(array $arg) {
$file_name = null; $file_name = null;
if (isset($arg[0]) && is_string($arg[0])) { if (isset($arg[0]) && is_string($arg[0])) {

@ -0,0 +1,16 @@
<?php
/**
* @author Robert Strutts <Robert@TryingToScale.com>
* @copyright Copyright (c) 2022, Robert Strutts.
* @license https://mit-license.org/
*/
\main_tts\registry::get('di')->register('session_encryption', function($args) {
try {
$key = \main_tts\configure::get('sessions', 'session_key');
return new \tts\services\paragon_crypto\sodium_storage($key);
} catch (\Exception $e) {
}
});

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1);
\main_tts\registry::get('di')->register('templates', function(array $arg) { \main_tts\registry::get('di')->register('templates', function(array $arg) {
$file_type = '.tpl'; $file_type = '.tpl';
if (isset($arg[0]) && is_string($arg[0])) { if (isset($arg[0]) && is_string($arg[0])) {

@ -1,7 +1,5 @@
<?php <?php
declare(strict_types=1);
\main_tts\registry::get('di')->register('db_mocker', function($args) { \main_tts\registry::get('di')->register('db_mocker', function($args) {
try { try {
$conn = new \PDO('sqlite::memory:'); $conn = new \PDO('sqlite::memory:');

Loading…
Cancel
Save