public static void DecryptFile(FileInfo file, byte[] key)
        {
            if (file == null || !file.Exists)
            {
                throw new FileNotFoundException();
            }

            var bytes   = File.ReadAllBytes(file.FullName);
            var tmpName = file.FullName + ".tmp";

            try
            {
                using (var fileStream =
                           new FileStream(tmpName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
                {
                    var m = WeakSymmetricEncryption.Decrypt(bytes, key, WeakCryptoConfig.SaltSizeBytes);
                    fileStream.Write(m, 0, m.Length);
                }
                File.Delete(file.FullName);
                File.Move(tmpName, tmpName.Replace(".falsecrypt.tmp", ""));
            }
            catch (Exception)
            {
                File.Delete(file.FullName + ".tmp");
                throw;
            }
        }
        public static byte[] DecryptMessage(byte[] encryptedMessage, string password)
        {
            if (encryptedMessage == null || encryptedMessage.Length == 0)
            {
                throw new ArgumentException("Encrypted Message Required!", nameof(encryptedMessage));
            }

            var data = WeakPasswordDerivation.DerivePassword(password);

            return(WeakSymmetricEncryption.Decrypt(encryptedMessage, data.Key, data.Salt.Length));
        }
        public static string DecryptMessage(string encryptedMessage, byte[] key, Encoding encoding)
        {
            if (string.IsNullOrWhiteSpace(encryptedMessage))
            {
                throw new ArgumentException("Encrypted Message Required!", nameof(encryptedMessage));
            }

            var cipherText = Convert.FromBase64String(encryptedMessage);
            var plainText  = WeakSymmetricEncryption.Decrypt(cipherText, key, 0);

            return(plainText == null ? null : Encoding.UTF8.GetString(plainText));
        }