/** * Test scrypt correct size output */ public function testScryptSize() { for ($size = 0; $size < 64; $size++) { if (extension_loaded('Scrypt') && $size < 16) { $this->setExpectedException('Zend\\Crypt\\Key\\Derivation\\Exception\\InvalidArgumentException'); } $result = Scrypt::calc('test', 'salt', 16, 1, 1, $size); $this->assertEquals($size, strlen($result)); } }
/** * Generate a key and return in 'friendly' format. * * @param string $salt - optional 32 byte salt (if not supplied one will be generated).. * * @return string - friendly */ public function generate_key($salt = null) { $salt = mb_strlen($salt) === 32 ? $salt : Rand::getBytes(32, true); $pass = Rand::getBytes(32, true); return $this->friendly(KeyGen::calc($pass, $salt, 2048, 2, 1, 32)); }