Указанный режим заполнения недопустим для этого алгоритма System.Security.Cryptography.CryptographicException in. net core - PullRequest
0 голосов
/ 23 марта 2020

// Я также получаю ошибку, как показано ниже в упомянутом коде // System.Security.Cryptography.CryptographicException: указанный режим заполнения недопустим для этого // алгоритма

      public static string Decrypt(string text, ActionExecutingContext actionContext)
        {
            byte[] byKey = new byte[] { };
            byte[] IV = new byte[] { 18, 52, 86, 120, 144, 171, 205, 239 };

            MemoryStream ms = null;
            CryptoStream cs = null;
            string output = string.Empty;
            string decryptKey = "tr45334";

            try
            {
                byKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 8));
                byte[] inputByteArray = Convert.FromBase64String(text);

                DESCryptoServiceProvider des = new DESCryptoServiceProvider();

                ms = new MemoryStream();
                cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
               inputByteArray.Length - IV.Length);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();

                output = Encoding.UTF8.GetString(ms.ToArray());
            }
            catch (Exception ex)
            {
                output = "F";


            }
            finally
            {
                if (cs != null)
                    cs.Close();
                if (ms != null)
                    ms.Close();
            }
            return output;
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...