mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
WIP Protect/Unprotect Additional Field on selection
This commit is contained in:
@@ -74,6 +74,24 @@ namespace ModernKeePass.Infrastructure.UWP
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task WriteToLogFile(IEnumerable<string> data)
|
||||
{
|
||||
var local = ApplicationData.Current.LocalFolder;
|
||||
var logFile = await local.CreateFileAsync("LogFile.txt", CreationCollisionOption.OpenIfExists).AsTask();
|
||||
|
||||
if (logFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
await FileIO.AppendLinesAsync(logFile, data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// If another option is available to the app to log error(i.e. Azure Mobile Service, etc...) then try that here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseFile(string path)
|
||||
{
|
||||
StorageApplicationPermissions.FutureAccessList.Remove(path);
|
||||
|
@@ -12,27 +12,21 @@ namespace ModernKeePass.Infrastructure.UWP
|
||||
public async Task<string> Protect(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return value;
|
||||
try
|
||||
{
|
||||
// Create a DataProtectionProvider object for the specified descriptor.
|
||||
var provider = new DataProtectionProvider("LOCAL=user");
|
||||
|
||||
// Encode the plaintext input message to a buffer.
|
||||
var buffMsg = CryptographicBuffer.ConvertStringToBinary(value, BinaryStringEncoding.Utf8);
|
||||
|
||||
// Encrypt the message.
|
||||
var buffProtected = await provider.ProtectAsync(buffMsg).AsTask().ConfigureAwait(false);
|
||||
|
||||
// Encode buffer to Base64
|
||||
var protectedValue = CryptographicBuffer.EncodeToBase64String(buffProtected);
|
||||
// Create a DataProtectionProvider object for the specified descriptor.
|
||||
var provider = new DataProtectionProvider("LOCAL=user");
|
||||
|
||||
// Encode the plaintext input message to a buffer.
|
||||
var buffMsg = CryptographicBuffer.ConvertStringToBinary(value, BinaryStringEncoding.Utf8);
|
||||
|
||||
// Return the encrypted string.
|
||||
return protectedValue;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
// Encrypt the message.
|
||||
var buffProtected = await provider.ProtectAsync(buffMsg).AsTask().ConfigureAwait(false);
|
||||
|
||||
// Encode buffer to Base64
|
||||
var protectedValue = CryptographicBuffer.EncodeToBase64String(buffProtected);
|
||||
|
||||
// Return the encrypted string.
|
||||
return protectedValue;
|
||||
}
|
||||
|
||||
public async Task<string> UnProtect(string value)
|
||||
|
Reference in New Issue
Block a user