@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $this->assertNotNull($message); |
| 58 | 58 | $this->assertTrue($message instanceof TextMessage); |
| 59 | - if($message instanceof TextMessage) { |
|
| 59 | + if ($message instanceof TextMessage) { |
|
| 60 | 60 | $this->assertEquals($message->getText(), 'Dies ist eine Testnachricht. äöü'); |
| 61 | 61 | } |
| 62 | 62 | }); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | public function testDerivePublicKey() { |
| 95 | - $this->doTest(function(CryptTool $cryptTool, $prefix){ |
|
| 95 | + $this->doTest(function(CryptTool $cryptTool, $prefix) { |
|
| 96 | 96 | $publicKey = $cryptTool->derivePublicKey($cryptTool->hex2bin(Common::getPrivateKey(Constants::myPrivateKey))); |
| 97 | 97 | $myPublicKey = $cryptTool->hex2bin(Common::getPublicKey(Constants::myPublicKey)); |
| 98 | 98 | |
@@ -165,17 +165,17 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | // test different strings when comparing and get time needed |
| 167 | 167 | $result = []; |
| 168 | - foreach(array( |
|
| 169 | - 'length' => [$string1, $string1 . 'a'], |
|
| 168 | + foreach (array( |
|
| 169 | + 'length' => [$string1, $string1.'a'], |
|
| 170 | 170 | 'diff' => [$string1, $string2], |
| 171 | 171 | 'same' => [$string1, $string1] |
| 172 | 172 | ) as $testName => $strings) { |
| 173 | 173 | $timeStart = microtime(true); |
| 174 | - for ($i=0; $i < 3; $i++) { |
|
| 174 | + for ($i = 0; $i < 3; $i++) { |
|
| 175 | 175 | $comparisonResult = $cryptTool->stringCompare($strings[0], $strings[1]); |
| 176 | 176 | } |
| 177 | 177 | $timeEnd = microtime(true); |
| 178 | - $timeElapsed = $timeEnd - $timeStart; |
|
| 178 | + $timeElapsed = $timeEnd-$timeStart; |
|
| 179 | 179 | |
| 180 | 180 | // echo $prefix.': '.$humanDescr[$testName].': '.$timeElapsed.'; result: '.$comparisonResult.PHP_EOL; |
| 181 | 181 | $result[$testName] = [$timeElapsed, $comparisonResult]; |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | // check timings |
| 192 | 192 | echo 'Timing test results with '.$prefix.':'.PHP_EOL; |
| 193 | - $timingRatio = $result['diff'][0] / $result['same'][0]; |
|
| 194 | - $absoluteDifference = abs($result['diff'][0] - $result['same'][0]); |
|
| 193 | + $timingRatio = $result['diff'][0]/$result['same'][0]; |
|
| 194 | + $absoluteDifference = abs($result['diff'][0]-$result['same'][0]); |
|
| 195 | 195 | echo 'timing ratio: '.$timingRatio.PHP_EOL; |
| 196 | 196 | echo 'absolute difference: '.$absoluteDifference.PHP_EOL; |
| 197 | 197 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function testRemoveVar() { |
| 212 | 212 | $this->doTest(function(CryptTool $cryptTool, $prefix) { |
| 213 | - foreach(array( |
|
| 213 | + foreach (array( |
|
| 214 | 214 | 'hex' => Constants::myPrivateKeyExtract, |
| 215 | 215 | 'bin' => $cryptTool->hex2bin(Constants::myPrivateKeyExtract) |
| 216 | 216 | ) as $key => $testVar) { |
@@ -224,12 +224,12 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | private function doTest(\Closure $c) { |
| 227 | - foreach(array( |
|
| 227 | + foreach (array( |
|
| 228 | 228 | 'Salt' => CryptTool::createInstance(CryptTool::TYPE_SALT), |
| 229 | 229 | 'Sodium' => CryptTool::createInstance(CryptTool::TYPE_SODIUM) |
| 230 | 230 | ) as $key => $instance) { |
| 231 | 231 | |
| 232 | - if($instance === null) { |
|
| 232 | + if ($instance === null) { |
|
| 233 | 233 | echo $key.": could not instance crypt tool\n"; |
| 234 | 234 | break; |
| 235 | 235 | } |