I have code written in C# that creates DataProtector which then is used to protect tokens in config
C# code
//constructor code
var appLocalDir = Directory.CreateDirectory(Path.Combine(localApplicationData, "<example_dir>"));
var provider = DataProtectionProvider.Create(appLocalDir, builder => { builder.ProtectKeysWithDpapi(); });
_dataProtector = provider.CreateProtector("<example_purpose>");
//protector usage
public string Token
{
get
{
try
{
return _dataProtector.Unprotect(_token);
}
catch
{
_token = null;
return null;
}
}
set => _token = _dataProtector.Protect(value);
}
I need to create similar protector in python in order to save token retrieved by python code to be used by c# code.
Is there any python lib for such things? I need my python code to have exactly the same output as C#'s one in order to read the token using provided example
So far I couldn't find any solution that would work on windows 10.
Thanks
After checking many different solutions I found one that works for me. I used python.NET package to load required C# .dll files and used them in python code.