public List <string> LoadFile(string filePath, string base64key) { var key = Convert.FromBase64String(base64key); var contentLines = _fileService.ReadTextFile(filePath); var fileData = new FileEncryptionData(contentLines); var iv = fileData.GetInitVector(); return(fileData.TextLines .Select(line => _aesService.Decrypt(line, key, iv)) .ToList()); }
public void SaveFile(string filePath, IEnumerable <string> lines, string base64key) { var key = Convert.FromBase64String(base64key); var iv = _aesService.GenerateInitVector(); var fileData = new FileEncryptionData(iv) { TextLines = lines .Select(line => _aesService.Encrypt(line, key, iv)) .ToList() }; _fileService.SaveTextFile(filePath, fileData.ToFileContentLines()); }