public byte[] Read() { byte[] fileData = _unencryptedFileAccessor.Read(); if (fileData != null && fileData.Length > 0) { _logger.LogInformation($"Unprotecting the data"); fileData = ProtectedData.Unprotect(fileData, optionalEntropy: null, scope: DataProtectionScope.CurrentUser); } return(fileData); }
private static void ReadOrReadWriteClear(ICacheAccessor accessor) { Console.WriteLine(accessor.ToString()); var bytes = accessor.Read(); if (bytes == null || bytes.Length == 0) { Console.WriteLine("No data found, writing some"); accessor.Write(s_payload); var bytes2 = accessor.Read(); accessor.Clear(); Console.WriteLine("All good"); } else { string s = Encoding.UTF8.GetString(bytes); Console.WriteLine($"Found some data ... {s.Substring(0,20)}..."); Console.WriteLine("Stopping"); } }