private async void decrypt_button_Tapped(object sender, TappedRoutedEventArgs e) { string password = password_box.Text; if (!string.IsNullOrEmpty(password) || EncryptedFile != null) { // Open the file StorageFile sampleFile = (EncryptedFile as StorageFile); var buffer = await FileIO.ReadBufferAsync(sampleFile); DataReader dataReader = Windows.Storage.Streams.DataReader.FromBuffer(buffer); byte[] fileContent = new byte[dataReader.UnconsumedBufferLength]; dataReader.ReadBytes(fileContent); // Get private key byte[] privateKey = await KeyStore.Instance.GetMyPrivateKey(); if (privateKey != null) { string errors; byte[] result = PGP.Decrypt(fileContent, privateKey, password, out errors); if (result != null) { message_box.Text = Encoding.UTF8.GetString(result, 0, result.Length); } else { message_box.Text = "ERROR: " + errors; } } else { message_box.Text = "ERROR: you have no private key!"; } message_box.Visibility = Windows.UI.Xaml.Visibility.Visible; } }