Good all the time of day!
The project has the need to encrypt data. I downloaded the encryption code from the Internet. fiddled with him. Pretty changed ...
When I started testing, I noticed that the encryption procedure works perfectly, but the declining process refuses ...
// Процедура дешифрования public static string DecryptData(string data) { MemoryStream memorystream; StreamReader streamreader; CryptoStream crstream; // Определить алгоритм SymmetricAlgorithm Alg = DefineAlg(); ICryptoTransform Cryptor = CreateDec(Alg); // Получаем массив байтов byte[] bytedata = ToBytes(data); memorystream = new MemoryStream(bytedata); crstream = new CryptoStream(memorystream, Cryptor, CryptoStreamMode.Read); streamreader = new StreamReader(crstream); // Показываем результат string decdata = streamreader.ReadToEnd(); // Закрываем потоки crstream.Close(); streamreader.Close(); memorystream.Close(); return decdata; }
I can not understand why. Suspicions
string decdata = streamreader.ReadToEnd();
Maybe it's in the stream. When compiling, it flies away from here, and most importantly, no exceptions pop up ... Help me figure it out.
Thanks in advance.