/** * Derive an encryption key from a password and a salt * * @param string $password * @param string $salt * @param int $type * @return array|\ParagonIE\Halite\Key * @throws CryptoException\InvalidFlags */ public static function deriveFromPassword($password, $salt, $type = self::CRYPTO_SIGN) { if (Key::doesNotHaveFlag($type, Key::ASYMMETRIC)) { throw new CryptoException\InvalidKey('An asymmetric key type must be passed to KeyPair::generate()'); } if (Key::hasFlag($type, Key::SIGNATURE)) { $key = SignatureSecretKey::deriveFromPassword($password, $salt, Key::CRYPTO_SIGN); $keypair = new SignatureKeyPair($key[0]); return $keypair; } throw new CryptoException\InvalidKey('You must specify encryption or authentication flags.'); }