public void Write(byte[] data) { if (data.Length != 0) { _logger.LogInformation($"Protecting the data"); data = ProtectedData.Protect(data, optionalEntropy: null, scope: DataProtectionScope.CurrentUser); } _unencryptedFileAccessor.Write(data); }
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"); } }