private async void ProtectedAccessSuspending(object sender, ProtectedAccessSuspendingEventArgs args) { string logFileContent = ""; Windows.Foundation.Deferral deferal = args.GetDeferral(); // Protect any sensitive data in Memory so that it cannot be accessed while the device is locked // You should encrypt or destory any copies of sensitve data while device is going to a locked state. IBuffer inputBuffer = CryptographicBuffer.ConvertStringToBinary(m_SecretMessage, BinaryStringEncoding.Utf8); BufferProtectUnprotectResult procBuffer = await DataProtectionManager.ProtectAsync(inputBuffer, m_EnterpriseID); m_protectedBuffer = procBuffer.Buffer; deferal.Complete(); m_areKeysDropped = true; var settings = ApplicationData.Current.LocalSettings; settings.Values[m_taskName] += "\nApp got DPL suspend event"; StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile logFile = await localFolder.CreateFileAsync("SuspendLog.txt", CreationCollisionOption.OpenIfExists); logFileContent += "\r\n" + DateTime.Now + ":" + "Got DPL Protected Suspended"; logFileContent += "\r\n" + "Protection Status:" + procBuffer.ProtectionInfo.Status; await FileIO.AppendTextAsync(logFile, logFileContent); }
private async void ProtectedAccessSuspending(object sender, ProtectedAccessSuspendingEventArgs args) { string logFileContent = ""; Windows.Foundation.Deferral deferal = args.GetDeferral(); // Protect any sensitive data in Memory so that it cannot be accessed while the device is locked // You should encrypt or destory any copies of sensitve data while device is going to a locked state. IBuffer inputBuffer = CryptographicBuffer.ConvertStringToBinary(m_SecretMessage, BinaryStringEncoding.Utf8); BufferProtectUnprotectResult procBuffer = await DataProtectionManager.ProtectAsync(inputBuffer, m_EnterpriseID); m_protectedBuffer = procBuffer.Buffer; deferal.Complete(); m_areKeysDropped = true; var settings = ApplicationData.Current.LocalSettings; settings.Values[m_taskName] += "\nApp got DPL suspend event"; StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile logFile = await localFolder.CreateFileAsync("SuspendLog.txt", CreationCollisionOption.OpenIfExists); logFileContent += "\r\n" + DateTime.Now + ":" + "Got DPL Protected Suspended"; logFileContent += "\r\n" + "Protection Status:" + procBuffer.ProtectionInfo.Status; await FileIO.AppendTextAsync(logFile, logFileContent); }