public function testGetRandNumber() { $hash = array(); for ($i = 0; $i < 2000; $i++) { $r = _Rand::_getRand(0, 999999999); if (!isset($hash[$r])) { $hash[$r] = 1; } else { $hash[$r]++; } $this->assertLessThanOrEqual(999999999, $r); $this->assertGreaterThanOrEqual(0, $r); } // We generated 2000 numbers. Let's assume there may be some duplicates, but it's unlikely that there would be many $this->assertGreaterThanOrEqual(1950, count($hash)); }
public function testRSAEncryptDecrypt4096() { $keys = _Crypt::_generateRSAKeys(4096); for ($i = 0; $i < 5; $i++) { $txt = _Rand::_randString(_Rand::_getRand(1, 3000)); $key = _Rand::_randString(_Rand::_getRand(1, 3000)); $encrypted = _Crypt::_encryptRSA($txt, $keys['public']); $decrypted = _Crypt::_decryptRSA($encrypted, $keys['private'], 4096); $this->assertEquals($txt, $decrypted); } }