Skip to content

Commit

Permalink
Merge pull request #2 from Spomky-Labs/analysis-XNAOD1
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
Spomky committed Apr 29, 2016
2 parents 8972bf7 + f64665b commit c88ed75
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tests/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

include_once __DIR__.'/../vendor/autoload.php';

use AESGCM\AESGCM;
use Assert\Assertion;

/**
* This function allows developpers to test the encryption performance of the library on their environnement
* This function allows developpers to test the encryption performance of the library on their environnement.
*
* @param int $nb Number of encryption/decryption to perform
*/
function runEncryptionBenchmark($nb = 100)
{
Assertion::integer($nb, 'The argument must be an integer');
Assertion::greaterThan($nb, 1, 'The argument must be greater than 1');

$K = hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308');
$IV = hex2bin('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b');
$P = hex2bin('d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39');
$A = hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2');

print_r('################################'.PHP_EOL);
print_r('# AES-GCM ENCRYPTION BENCHMARK #'.PHP_EOL);
print_r('################################'.PHP_EOL);
Expand All @@ -39,25 +40,26 @@ function runEncryptionBenchmark($nb = 100)
$time_end = microtime(true);
$time = ($time_end - $time_start) / $nb * 1000;
printf('%f milliseconds/encryption (tested on %d encryptions)'.PHP_EOL, $time, $nb);

print_r('################################'.PHP_EOL);
}

/**
* This function allows developpers to test the decryption performance of the library on their environnement
* This function allows developpers to test the decryption performance of the library on their environnement.
*
* @param int $nb Number of encryption/decryption to perform
*/
function runDecryptionBenchmark($nb = 100)
{
Assertion::integer($nb, 'The argument must be an integer');
Assertion::greaterThan($nb, 1, 'The argument must be greater than 1');

$K = hex2bin('feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308');
$IV = hex2bin('9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b');
$C = hex2bin('5a8def2f0c9e53f1f75d7853659e2a20eeb2b22aafde6419a058ab4f6f746bf40fc0c3b780f244452da3ebf1c5d82cdea2418997200ef82e44ae7e3f');
$A = hex2bin('feedfacedeadbeeffeedfacedeadbeefabaddad2');
$T = hex2bin('a44a8266ee1c8eb0c8b5d4cf5ae9f19a');

print_r('################################'.PHP_EOL);
print_r('# AES-GCM DECRYPTION BENCHMARK #'.PHP_EOL);
print_r('################################'.PHP_EOL);
Expand All @@ -69,7 +71,7 @@ function runDecryptionBenchmark($nb = 100)
$time_end = microtime(true);
$time = ($time_end - $time_start) / $nb * 1000;
printf('%f milliseconds/decryption (tested on %d decryptions)'.PHP_EOL, $time, $nb);

print_r('################################'.PHP_EOL);
}

Expand Down

0 comments on commit c88ed75

Please sign in to comment.