public function testEntropy() { $match = new Bruteforce('99', 0, 1, '99'); $this->assertSame(log(pow(10, 2), 2), $match->getEntropy()); $password = '******'; $match = new Bruteforce($password, 0, 3, $password); $this->assertSame(95, $match->getCardinality()); $this->assertSame(log(pow(95, 4), 2), $match->getEntropy()); }
/** * Make a bruteforce match object for substring of password. * * @param string $password * @param int $begin * @param int $end * @param int $cardinality optional * * @return Bruteforce match */ protected function makeBruteforceMatch($password, $begin, $end, $cardinality = null) { $match = new Bruteforce($password, $begin, $end, substr($password, $begin, $end + 1), $cardinality); // Set entropy in match. $match->getEntropy(); return $match; }