Ejemplo n.º 1
0
        private async void ProtectedAccessResumed(object sender, ProtectedAccessResumedEventArgs args)
        {
            string logFileContent = "";

            // Keys are available so can read and write from a protected file

            m_areKeysDropped = false;

            //
            BufferProtectUnprotectResult unBuffer = await DataProtectionManager.UnprotectAsync(m_protectedBuffer);

            m_SecretMessage = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8,
                                                                        m_protectedBuffer
                                                                        );
            logFileContent += "\n Unprotected string:" + m_SecretMessage;

            var settings = ApplicationData.Current.LocalSettings;

            settings.Values[m_taskName] += "\nApp got DPL resumed event";

            StorageFolder localFolder =
                Windows.Storage.ApplicationData.Current.LocalFolder;

            StorageFile logFile = await localFolder.CreateFileAsync("ResumeLog.txt",
                                                                    CreationCollisionOption.OpenIfExists);

            await FileIO.AppendTextAsync(logFile, "\r\n" + DateTime.Now + ":" + "Got DPL Protected resumed");
        }
        private async void ProtectedAccessResumed(object sender, ProtectedAccessResumedEventArgs args)
        {
            // Keys are available so can read and write from a protected file
            
            m_areKeysDropped = false;
            
            BufferProtectUnprotectResult unBuffer = await DataProtectionManager.UnprotectAsync(m_protectedBuffer);
            m_SecretMessage = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8,
                                                                           m_protectedBuffer
                                                                           );
            string logFileContent = "\n Unprotected string:" + m_SecretMessage;

            var settings = ApplicationData.Current.LocalSettings;
            settings.Values[m_taskName] += "\nApp got DPL resumed event";
            StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            StorageFile logFile = await localFolder.CreateFileAsync("ResumeLog.txt",
                                                                       CreationCollisionOption.OpenIfExists);
            await FileIO.AppendTextAsync(logFile, "\r\n" + DateTime.Now + ":" + "Got DPL Protected resumed");
        }