public static function fromAlgorithmIdentifier(PBEAlgorithmIdentifier $algo,
        Crypto $crypto = null): PBEScheme
    {
        $crypto = $crypto ?: Crypto::getDefault();
        if ($algo instanceof PBES1AlgorithmIdentifier) {
            return new PBES1($algo->hashFunc(), $algo->blockCipher(),
                $algo->salt(), $algo->iterationCount(), $crypto);
        }
        if ($algo instanceof PBES2AlgorithmIdentifier) {
            $prf = PRF::fromAlgorithmIdentifier(
                $algo->kdfAlgorithmIdentifier()->prfAlgorithmIdentifier());
            return new PBES2($prf, $algo->esAlgorithmIdentifier(), $algo->salt(),
                $algo->iterationCount(), $crypto);
        }
        throw new \UnexpectedValueException(
            sprintf("No encryption scheme for %s algorithm.", $algo->name()));
    }
public static function fromAlgorithmIdentifier(PBEAlgorithmIdentifier $algo,
        Crypto $crypto = null): PBEScheme
    {
        $crypto = $crypto ?: Crypto::getDefault();
        if ($algo instanceof PBES1AlgorithmIdentifier) {
            return new PBES1($algo->hashFunc(), $algo->blockCipher(),
                $algo->salt(), $algo->iterationCount(), $crypto);
        }
        if ($algo instanceof PBES2AlgorithmIdentifier) {
            $prf = PRF::fromAlgorithmIdentifier(
                $algo->kdfAlgorithmIdentifier()->prfAlgorithmIdentifier());
            return new PBES2($prf, $algo->esAlgorithmIdentifier(), $algo->salt(),
                $algo->iterationCount(), $crypto);
        }
        throw new \UnexpectedValueException(
            sprintf("No encryption scheme for %s algorithm.", $algo->name()));
    }
public static function fromAlgorithmIdentifier ( PBEAlgorithmIdentifier $ algo , Crypto $ crypto = null ) : PBEScheme { $ crypto = $ crypto ? : Crypto :: getDefault ( ) ; if ( $ algo instanceof PBES1AlgorithmIdentifier ) { return new PBES1 ( $ algo -> hashFunc ( ) , $ algo -> blockCipher ( ) , $ algo -> salt ( ) , $ algo -> iterationCount ( ) , $ crypto ) ; } if ( $ algo instanceof PBES2AlgorithmIdentifier ) { $ prf = PRF :: fromAlgorithmIdentifier ( $ algo -> kdfAlgorithmIdentifier ( ) -> prfAlgorithmIdentifier ( ) ) ; return new PBES2 ( $ prf , $ algo -> esAlgorithmIdentifier ( ) , $ algo -> salt ( ) , $ algo -> iterationCount ( ) , $ crypto ) ; } throw new \ UnexpectedValueException ( sprintf ( "No encryption scheme for %s algorithm." , $ algo -> name ( ) ) ) ; }
Get PBEScheme by algorithm identifier.

@param PBEAlgorithmIdentifier $algo Algorithm identifier
@param Crypto|null $crypto Crypto engine, use default if not set
@throws \UnexpectedValueException
@return self
Get PBEScheme by algorithm identifier .