System.Security.Cryptography.AesManaged.CreateDecryptor C# (CSharp) Метод

CreateDecryptor() публичный Метод

public CreateDecryptor ( ) : ICryptoTransform
Результат ICryptoTransform
        public override ICryptoTransform CreateDecryptor() => _impl.CreateDecryptor();
        public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV) => _impl.CreateDecryptor(rgbKey, rgbIV);

Same methods

AesManaged::CreateDecryptor ( byte rgbKey, byte rgbIV ) : ICryptoTransform

Usage Example

Пример #1
13
        public static bool DecryptBase64(string cliperText, string key, out string originText)
        {
            byte[] inputData = Convert.FromBase64String(cliperText);

            var aes = new AesManaged()
            {
                Padding = _padding,
                Mode = _cipherMode,
                IV = ORIGIN_IV,
                Key = Encoding.UTF8.GetBytes(key.PadRight(KEY_LENGTH, PADDING_CHAR).Substring(0, KEY_LENGTH))
            };

            var decryptor = aes.CreateDecryptor();
            bool decryptSuccess = true;
            try
            {
                byte[] decryptedData = decryptor.TransformFinalBlock(inputData, 0, inputData.Length);
                originText = Encoding.UTF8.GetString(decryptedData);
            }
            catch
            {
                decryptSuccess = false;
                originText = string.Empty;
            }
            finally
            {
                decryptor.Dispose();
                if (aes != null)
                {
                    aes.Clear();
                }
            }
            return decryptSuccess;
        }
All Usage Examples Of System.Security.Cryptography.AesManaged::CreateDecryptor