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

getPBES2EncryptionObject() static public method

Returns a SymmetricKey object baesd on a PBES2 $algo
static public getPBES2EncryptionObject ( string $algo )
$algo string
    static function getPBES2EncryptionObject($algo)
    {
        switch ($algo) {
            case 'desCBC':
                $cipher = new TripleDES(BlockCipher::MODE_CBC);
                break;
            case 'des-EDE3-CBC':
                $cipher = new TripleDES(BlockCipher::MODE_CBC);
                break;
            case 'rc2CBC':
                $cipher = new RC2(BlockCipher::MODE_CBC);
                // in theory this can be changed
                $cipher->setKeyLength(128);
                break;
            case 'rc5-CBC-PAD':
                throw new UnsupportedAlgorithmException('rc5-CBC-PAD is not supported for PBES2 PKCS#8 keys');
            case 'aes128-CBC-PAD':
            case 'aes192-CBC-PAD':
            case 'aes256-CBC-PAD':
                $cipher = new AES(BlockCipher::MODE_CBC);
                $cipher->setKeyLength(substr($algo, 3, 3));
                break;
            default:
                throw new UnsupportedAlgorithmException("{$algo} is not supported");
        }
        return $cipher;
    }