public static void DecontainerizeDirectoryFiles(FolderModel masterModel, string folderPath, ContainerizationSettingsModel settingsModel, bool includeSubFolders)
        {
            foreach (var filePath in Directory.GetFiles(folderPath).Where(x => Path.GetExtension(x).Equals(settingsModel.Extension)))
            {
                ContainerHelper.DecontainerizeFile(filePath, settingsModel.Password);

                var fileModel = folderPath.Equals(masterModel.Uri)
                    ? masterModel.FileModels.FirstOrDefault(x => x.Secured.Equals(filePath))
                    : GetFileModel(masterModel, file => file.Secured.Equals(filePath));

                var newPath = FileGeneratorHelper.GetValidFileNameForDirectory(
                    GetDirectoryPath(filePath),
                    Path.GetFileNameWithoutExtension(filePath),
                    fileModel != null ? Path.GetExtension(fileModel.File) : string.Empty);

                File.Move(filePath, newPath);
            }

            if (!includeSubFolders)
            {
                return;
            }

            foreach (var subFolderPath in Directory.GetDirectories(folderPath))
            {
                DecontainerizeDirectoryFiles(masterModel, subFolderPath, settingsModel, true);
            }
        }
        public static RSAParameters GetParameters(string path, string password)
        {
            ContainerHelper.DecontainerizeFile(path, password);

            RSAParameters key = default;

            using (var fs = new FileStream(path, FileMode.Open))
            {
                if (new BinaryFormatter().Deserialize(fs) is RSAParameters parameters)
                {
                    key = parameters;
                }
            }
            ContainerHelper.ContainerizeFile(path, AesHelper.GetNewAesKey(), password);

            return(key);
        }
        public static IEnumerable <FileModel> EnumerateAndSecureFiles(string folderPath, ContainerizationSettingsModel settingsModel)
        {
            var fileModels = new List <FileModel>();

            foreach (var filePath in Directory.GetFiles(folderPath).Where(x => !Path.GetExtension(x).Equals(settingsModel.Extension)))
            {
                ContainerHelper.ContainerizeFile(filePath, AesHelper.GetNewAesKey(), settingsModel.Password);
                var newPath = FileGeneratorHelper.GetValidFileNameForDirectory(
                    GetDirectoryPath(filePath),
                    Path.GetFileNameWithoutExtension(filePath),
                    settingsModel.Extension);

                File.Move(filePath, newPath);

                fileModels.Add(new FileModel
                {
                    File    = Path.GetFileName(filePath),
                    Time    = DateTime.Now,
                    Secured = newPath
                });
            }

            return(fileModels);
        }