phpseclib\Crypt\Common\PKCS8::getPBES1EncryptionObject PHP Method

getPBES1EncryptionObject() static public method

Returns a SymmetricKey object based on a PBES1 $algo
static public getPBES1EncryptionObject ( string $algo )
$algo string
    static function getPBES1EncryptionObject($algo)
    {
        $algo = preg_match('#^pbeWith(?:MD2|MD5|SHA1|SHA)And(.*?)-CBC$#', $algo, $matches) ? $matches[1] : substr($algo, 13);
        // strlen('pbeWithSHAAnd') == 13
        switch ($algo) {
            case 'DES':
                $cipher = new DES(BlockCipher::MODE_CBC);
                break;
            case 'RC2':
                $cipher = new RC2(BlockCipher::MODE_CBC);
                break;
            case '3-KeyTripleDES':
                $cipher = new TripleDES(BlockCipher::MODE_CBC);
                break;
            case '2-KeyTripleDES':
                $cipher = new TripleDES(BlockCipher::MODE_CBC);
                $cipher->setKeyLength(128);
                break;
            case '128BitRC2':
                $cipher = new RC2(BlockCipher::MODE_CBC);
                $cipher->setKeyLength(128);
                break;
            case '40BitRC2':
                $cipher = new RC2(BlockCipher::MODE_CBC);
                $cipher->setKeyLength(40);
                break;
            case '128BitRC4':
                $cipher = new RC4();
                $cipher->setKeyLength(128);
                break;
            case '40BitRC4':
                $cipher = new RC4();
                $cipher->setKeyLength(40);
                break;
            default:
                throw new UnsupportedAlgorithmException("{$algo} is not a supported algorithm");
        }
        return $cipher;
    }