[C#]problem odszywrowywania-Stream does not support seeking

0

Robię szyfrator - deszyfrator - nic wielkiego ale przy odszyfrowaniu mam błąd
base {"Stream does not support seeking."} System.SystemException {System.NotSupportedException}

funkcja odszyfrowująca nic specjalnego - jakich wiele w internecie w przykładach

public static String decryptStringFromBytesAES(byte[] cipherText, byte[] Key, byte[] IV)
        {
            if (cipherText == null || cipherText.Length <= 0)
                throw new ArgumentNullException("cipherText");
            if (Key == null || Key.Length <= 0)
                throw new ArgumentNullException("Key");
            if (IV == null || IV.Length <= 0)
                throw new ArgumentNullException("Key");

            MemoryStream msDecrypt = null;
            CryptoStream csDecrypt = null;
            StreamReader srDecrypt = null;

            RijndaelManaged aesAlg = null;

            string plaintext = null;

            try
            {
                aesAlg = new RijndaelManaged();
                aesAlg.Key = Key;
                aesAlg.IV = IV;

                ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);

                msDecrypt = new MemoryStream(cipherText);
                csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read);//tu zaczynają sie problemy


                srDecrypt = new StreamReader(csDecrypt);//tu się objawiają

                plaintext = srDecrypt.ReadToEnd();
            }
            finally
            {
                if (srDecrypt != null)
                    srDecrypt.Close();
                if (csDecrypt != null)
                    csDecrypt.Close();
                if (msDecrypt != null)
                    msDecrypt.Close();

                if (aesAlg != null)
                    aesAlg.Clear();
            }

            return plaintext;

        }

jak sobie z tym poradzić

0

mozesz zalaczyc pelny stacktrace? jezeli nic na nim nie widac z wnetrza streamow, wylacz opcje 'just my code'. ogolnie, strumienie kompresji/szyfrowania faktycznie nie obsluguja :Seek, ale ani inicjalizacja StreamReader ani ReadToEnd nie sadze zeby uzywaly tej metody

1 użytkowników online, w tym zalogowanych: 0, gości: 1