Signing data
To prove that some data has come from someone we trust, it can be signed. Actually, you don't sign the data itself; instead, you sign a hash of the data. We will use the RSA algorithm combined with the SHA256 algorithm.
Signing with SHA256 and RSA
In the Ch11_CryptographyLib
class library project, add the following code to the Protector
class:
public static string PublicKey; public static string ToXmlString( 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...