Signing with SHA256 and RSA

In the CryptographyLib class library project, add the following code to the Protector class:

public static string PublicKey; 
 
public static string ToXmlStringExt(this RSA rsa, bool includePrivateParameters) 
{ 
   var p = rsa.ExportParameters(includePrivateParameters); 
   XElement xml; 
   if (includePrivateParameters) 
   { 
      xml = new XElement("RSAKeyValue" 
          , new XElement("Modulus",           Convert.ToBase64String(p.Modulus)) 
          , new XElement("Exponent",           Convert.ToBase64String(p.Exponent)) 
          , new XElement("P", Convert.ToBase64String(p.P)) 
          , new XElement("Q", Convert.ToBase64String(p.Q)) 
          , new XElement("DP", Convert.ToBase64String(p.DP)) 
          , new XElement("DQ", Convert.ToBase64String(p.DQ)) 
          , new XElement("InverseQ",  Convert.ToBase64String(p.InverseQ))); ...

Get C# 7.1 and .NET Core 2.0 – Modern Cross-Platform Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.