Winapi.Security.Cryptography contains wrappers for
Windows.Security.Cryptography.Core (Windows UWP)
Check this page first:
https://learn.microsoft.com/en-us/uwp/api/windows.security.cryptography.core.asymmetrickeyalgorithmprovider?view=winrt-22621
There is a C# app example that demonstrates how to use this interface.
Details about IBuffer can be found on this page:
https://learn.microsoft.com/en-us/uwp/api/windows.storage.streams.ibuffer?view=winrt-22621
This is probably your first step, if you want encrypt with RSA PKCS1:
uses
System.Win.WinRT,
Winapi.WinRT,
Winapi.Security.Cryptography,
Winapi.Storage.Streams;
const
KeyLength = 512;
var
objAlgProv: Core_IAsymmetricKeyAlgorithmProvider;
data: TBytes;
cleardata, encrypted: IBuffer;
key: Core_ICryptographicKey;
hs: HSTRING;
EncryptedBase64: string;
begin
data := TEncoding.UTF8.GetBytes('clear text');
objAlgProv := TCore_AsymmetricKeyAlgorithmProvider.OpenAlgorithm(TCore_AsymmetricAlgorithmNames.RsaPkcs1);
key := objAlgProv.CreateKeyPair(KeyLength);
cleardata := TCryptographicBuffer.CreateFromByteArray(length(data), @data[0]);
encrypted := TCore_CryptographicEngine.Encrypt(key, cleardata, nil {IV});
hs := TCryptographicBuffer.EncodeToBase64String(encrypted);
EncryptedBase64 := TWindowsString.HStringToString(hs);
end;
If you have further trouble translating the solution into Delphi, show your code an explain the details what you need to know.
Windows.Security.Cryptography.Core.AsymmetricKeyAlgorithmProvider.ImportKeyPair
concerned, you can Read text from a file by using a buffer(IBuffer) according to Create, write, and read a file.