DES decryption error "Bad Data" in C#.NET when closing cryptostream
I try to decrypt an  encrypted byte array (encrypt with K1 and decrypt with K2). Visual Studio throws an execption "BAD DATA" when it tries to close my crypto stream

here's my code snippet of DES decryption

    public Byte[] Decrypt(Byte[] cipherData, Byte[] key, Byte[] iv)
        {
            MemoryStream ms = new MemoryStream();
            DES mDES = DES.Create();
            mDES.Key = key;
            mDES.IV = iv;
            mDES.Padding = PaddingMode.PKCS7;
            CryptoStream cs = new CryptoStream(ms, mDES.CreateDecryptor(), CryptoStreamMode.Write);
            cs.Write(cipherData, 0, cipherData.Length);
            cs.Close();
            Byte[] decryptedData = ms.ToArray();
            return decryptedData;
        }

the initial vector is the same as encryption. I don't know why this error occured. 
Any suggestion to correct this error is appreciated

Best Regards,
LE Hai-Binh
DES decryption error "Bad Data" in C#.NET when closing cryptostream
===

I try to decrypt an  encrypted byte array (encrypt with K1 and decrypt with K2). Visual Studio throws an execption "BAD DATA" when it tries to close my crypto stream

here's my code snippet of DES decryption

    public Byte[] Decrypt(Byte[] cipherData, Byte[] key, Byte[] iv)
        {
            MemoryStream ms = new MemoryStream();
            DES mDES = DES.Create();
            mDES.Key = key;
            mDES.IV = iv;
            mDES.Padding = PaddingMode.PKCS7;
            CryptoStream cs = new CryptoStream(ms, mDES.CreateDecryptor(), CryptoStreamMode.Write);
            cs.Write(cipherData, 0, cipherData.Length);
            cs.Close();
            Byte[] decryptedData = ms.ToArray();
            return decryptedData;
        }

the initial vector is the same as encryption. I don't know why this error occured. 
Any suggestion to correct this error is appreciated

Best Regards,
LE Hai-Binh