При прохождении Апострофа в названии компании "компания" выдает ошибку
Ошибка
Invalid length for a Base-64 char array or string.
public string Decrypt(string dataToDecrypt) { byte[] data = Convert.FromBase64String(dataToDecrypt.Replace(' ', '+')); string decryptedData = string.Empty; try { //ReDim Preserve data(DataLen - 1) // The key and initialization vector : change them for your application byte[] _key = { 132, 42, 53, 124, 75, 56, 87, 38, 9, 10, 161, 132, 183, 91, 105, 16, 117, 218, 149, 230, 221, 212, 235, 64 }; byte[] _iv = { 83, 71, 26, 58, 54, 35, 22, 11, 83, 71, 26, 58, 54, 35, 22, 11 }; MemoryStream mStream = new MemoryStream(data, 0, data.Length); // instead of writing the decrypted text RijndaelManaged aes = new RijndaelManaged(); CryptoStream cs = new CryptoStream(mStream, aes.CreateDecryptor(_key, _iv), CryptoStreamMode.Read); StreamReader sr = new StreamReader(cs); ASCIIEncoding ut = new ASCIIEncoding(); string ab = sr.ReadToEnd(); //UTF8Encoding decryptedData = ab; return ab; } catch (Exception ex) { throw ex; } }
Что я уже пробовал:
byte[] data = Convert.FromBase64String(dataToDecrypt);