public string DoDecrypt(string symmetricBlockAlgorithm, string symmetricBlockMode,
                                string symmetricBlockPadding, string key, string IV, string encryptedInput)
        {
            this.error.cleanError();
            SymmetricBlockAlgorithm algorithm = SymmetricBlockAlgorithmUtils.getSymmetricBlockAlgorithm(symmetricBlockAlgorithm, this.error);
            SymmetricBlockMode      mode      = SymmetricBlockModeUtils.getSymmetricBlockMode(symmetricBlockMode, this.error);
            SymmetricBlockPadding   padding   = SymmetricBlockPaddingUtils.getSymmetricBlockPadding(symmetricBlockPadding, this.error);

            if (this.error.existsError())
            {
                return("");
            }

            BufferedBlockCipher bbc = getCipher(algorithm, mode, padding);

            if (this.error.existsError() && !(string.Compare(this.error.Code, "SB016", true) == 0))
            {
                return("");
            }
            byte[] bytesKey = SecurityUtils.GetHexa(key, "SB023", this.error);
            byte[] bytesIV  = SecurityUtils.GetHexa(IV, "SB023", this.error);
            if (this.HasError())
            {
                return("");
            }

            KeyParameter keyParam = new KeyParameter(bytesKey);

            if (SymmetricBlockMode.ECB != mode && SymmetricBlockMode.OPENPGPCFB != mode)
            {
                ParametersWithIV keyParamWithIV = new ParametersWithIV(keyParam, bytesIV);
                try
                {
                    bbc.Init(false, keyParamWithIV);
                }catch (Exception e)
                {
                    this.error.setError("SB027", e.Message);
                    return("");
                }
            }
            else
            {
                try
                {
                    bbc.Init(false, keyParam);
                }catch (Exception e)
                {
                    this.error.setError("SB028", e.Message);
                    return("");
                }
            }

            byte[] out2            = Base64.Decode(encryptedInput);
            byte[] comparisonBytes = new byte[bbc.GetOutputSize(out2.Length)];
            int    length          = bbc.ProcessBytes(out2, 0, out2.Length, comparisonBytes, 0);

            try
            {
                bbc.DoFinal(comparisonBytes, length);
            }
            catch (Exception)
            {
                this.error.setError("SB015", "Block decryption exception");
                return("");
            }
            this.error.cleanError();

            EncodingUtil eu = new EncodingUtil();

            this.error = eu.GetError();
            return(eu.getString(comparisonBytes));
        }
        public string DoEncrypt(string symmetricBlockAlgorithm, string symmetricBlockMode,
                                string symmetricBlockPadding, string key, string IV, string plainText)
        {
            this.error.cleanError();
            SymmetricBlockAlgorithm algorithm = SymmetricBlockAlgorithmUtils.getSymmetricBlockAlgorithm(symmetricBlockAlgorithm, this.error);
            SymmetricBlockMode      mode      = SymmetricBlockModeUtils.getSymmetricBlockMode(symmetricBlockMode, this.error);
            SymmetricBlockPadding   padding   = SymmetricBlockPaddingUtils.getSymmetricBlockPadding(symmetricBlockPadding, this.error);

            if (this.error.existsError())
            {
                return("");
            }

            BufferedBlockCipher bbc = getCipher(algorithm, mode, padding);

            if (this.error.existsError() && !(string.Compare(this.error.Code, "SB016", true) == 0))
            {
                return("");
            }
            byte[] byteIV  = SecurityUtils.GetHexa(IV, "SB022", this.error);
            byte[] byteKey = SecurityUtils.GetHexa(key, "SB022", this.error);
            if (this.HasError())
            {
                return("");
            }
            KeyParameter keyParam = new KeyParameter(byteKey);

            if (SymmetricBlockMode.ECB != mode && SymmetricBlockMode.OPENPGPCFB != mode)
            {
                ParametersWithIV keyParamWithIV = new ParametersWithIV(keyParam, byteIV);
                try{
                    bbc.Init(true, keyParamWithIV);
                }catch (Exception e)
                {
                    this.error.setError("SB025", e.Message);
                    return("");
                }
            }
            else
            {
                try
                {
                    bbc.Init(true, keyParam);
                }catch (Exception e)
                {
                    this.error.setError("SB026", e.Message);
                    return("");
                }
            }

            EncodingUtil eu = new EncodingUtil();

            byte[] inputBytes = eu.getBytes(plainText);
            if (eu.GetError().existsError())
            {
                this.error = eu.GetError();
                return("");
            }
            byte[] outputBytes = new byte[bbc.GetOutputSize(inputBytes.Length)];
            int    length      = bbc.ProcessBytes(inputBytes, 0, inputBytes.Length, outputBytes, 0);

            try
            {
                bbc.DoFinal(outputBytes, length);
            }
            catch (Exception)
            {
                this.error.setError("SB013", "Block encryption exception");
                return("");
            }
            string result = Base64.ToBase64String(outputBytes);

            if (result == null || result.Length == 0)
            {
                this.error.setError("SB014", "Error encoding base64");
                return("");
            }
            this.error.cleanError();
            return(result);
        }