March 2016
Intermediate to advanced
550 pages
10h 57m
English
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.
In the Ch11_Cryptography class library project, add the following code to the Protector class:
public static string PublicKey; public static string GenerateSignature(string data) { byte[] dataBytes = Encoding.Unicode.GetBytes(data); var sha = SHA256.Create(); var hashedData = sha.ComputeHash(dataBytes); var rsa = RSA.Create(); PublicKey = rsa.ToXmlString(false); // exclude private key var signer = new RSAPKCS1SignatureFormatter(rsa); signer.SetHashAlgorithm("SHA256"); return Convert.ToBase64String(signer.CreateSignature(hashedData)); ...Read now
Unlock full access