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ć