We will use the Bouncy Castle extension to decrypt the data passed over from Moodle by the API--refer to https://www.bouncycastle.org/ for details. This extension needs to be added to the project in the same manner as the XML-RPC library.
Let's create a new class to handle the data. From the Solution Explorer, right-click on the project name, slide down to Add and then select the Class... option:
We used two methods to decode the data. The first, to extract the private key details (recall that Moodle will use our public key to encrypt the data and only we can decrypt it because we should be the only ones in possession of the private key), GetPrivateKey() has been called. It is passed a string that references a path to the private key file:
public static RsaPrivateCrtKeyParameters GetPrivateKey(String pemFile)
{
if (string.IsNullOrEmpty(pemFile))
...