48 lines
2.0 KiB
PHP
48 lines
2.0 KiB
PHP
<?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);
|
|
}
|
|
|
|
// Full Circle simple data collection test
|
|
public function testFullCircleDataCollectionComplex() {
|
|
$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);
|
|
}
|
|
|
|
|
|
} |