by Pieter Philippaerts [Pieter at mentalis dot org] posted on 2004/06/14 |
|
The hashing- and signature classes are part of the normal .NET framework. Typically you'd use the MD5CryptoServiceProvider or SHA1CryptoServiceProvider class [from the System.Security.Cryptography namespace] to hash data and then one of the AsymmetricSignatureFormatters to sign it.
Here's some code that may help you on your way:
using System;
using System.Security.Cryptography;
using Org.Mentalis.Security.Certificates;
string text = ...;
byte[] text_bytes = Encoding.UTF8.GetBytes(text);
Certificate spc = ...;
MD5 md5 = MD5.Create();
md5.TransformFinalBlock(text_bytes, 0, text_bytes.Length);
AsymmetricSignatureFormatter asf = new RSAPKCS1SignatureFormatter(spc.PrivateKey);
byte[] signature = asf.CreateSignature(md5); |