2024-04-17 21:43:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\AppBundle;
|
|
|
|
|
|
|
|
include_once __DIR__.'/../vendor/autoload.php';
|
|
|
|
require_once __DIR__.'/../src/class.NumberBaseCrypt.php';
|
|
|
|
require_once __DIR__.'/../src/class.NumberBaseCryptCollection.php';
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class test extends TestCase {
|
|
|
|
|
|
|
|
// Full Circle simple data collection test
|
|
|
|
public function testFullCircleDataCollectionSimple() {
|
|
|
|
$data = [1337,1338,11111,141415,12,5];
|
|
|
|
$numberBaseCryptCollection = new \NAE\Crypt\NumberBaseCryptCollection([
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
|
|
'a', 'b', 'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
|
|
|
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
|
|
|
]);
|
|
|
|
foreach($data as $value) {
|
|
|
|
$numberBaseCryptCollection->addData($value);
|
|
|
|
}
|
|
|
|
$dataCollection = $numberBaseCryptCollection->render();
|
|
|
|
$digits = $numberBaseCryptCollection->getDigits();
|
|
|
|
$reverse = $numberBaseCryptCollection->decrypt($dataCollection, $digits);
|
|
|
|
$this->assertEquals($data, $reverse);
|
|
|
|
}
|
|
|
|
|
2024-04-19 22:42:18 +02:00
|
|
|
// test correct data is stored in the collection
|
|
|
|
public function testDataStorages() {
|
|
|
|
$data = [1337,1338,11111,141415,12,5];
|
|
|
|
$numberBaseCryptCollection = new \NAE\Crypt\NumberBaseCryptCollection([
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
|
|
'a', 'b', 'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
|
|
|
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
|
|
|
]);
|
|
|
|
foreach($data as $value) {
|
|
|
|
$numberBaseCryptCollection->addData($value);
|
|
|
|
}
|
|
|
|
$this->assertEquals($data, $numberBaseCryptCollection->getPlainData());
|
|
|
|
}
|
|
|
|
|
2024-04-19 22:53:12 +02:00
|
|
|
// Full Circle simple data collection test with a single element
|
|
|
|
public function testFullCircleDataCollectionComplexSingle() {
|
|
|
|
$data = [1337];
|
|
|
|
$numberBaseCryptCollection = new \NAE\Crypt\NumberBaseCryptCollection([
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
|
|
'a', 'b', 'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
|
|
|
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
|
|
|
]);
|
|
|
|
foreach($data as $value) {
|
|
|
|
$numberBaseCryptCollection->addData($value);
|
|
|
|
}
|
|
|
|
$dataCollection = $numberBaseCryptCollection->render();
|
|
|
|
$digits = $numberBaseCryptCollection->getDigitList();
|
|
|
|
$reverse = $numberBaseCryptCollection->decryptComplex($dataCollection, $digits);
|
|
|
|
$this->assertEquals($data, $reverse);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Full Circle simple data collection test with multiple elements
|
|
|
|
public function testFullCircleDataCollectionComplexMulti() {
|
2024-04-17 21:43:30 +02:00
|
|
|
$data = [1337,1338,11111,141415,12,5];
|
|
|
|
$numberBaseCryptCollection = new \NAE\Crypt\NumberBaseCryptCollection([
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
|
|
|
'a', 'b', 'c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
|
|
|
|
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
|
|
|
|
]);
|
|
|
|
foreach($data as $value) {
|
|
|
|
$numberBaseCryptCollection->addData($value);
|
|
|
|
}
|
|
|
|
$dataCollection = $numberBaseCryptCollection->render();
|
|
|
|
$digits = $numberBaseCryptCollection->getDigitList();
|
|
|
|
$reverse = $numberBaseCryptCollection->decryptComplex($dataCollection, $digits);
|
|
|
|
$this->assertEquals($data, $reverse);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|