views:

30

answers:

0
byte[] plaintext = System.Text.Encoding.UTF8.GetBytes("AAAAAAAAAAAAA");

TextReader trCer = new StreamReader(@"AA.key"); //key in PEM format

PemReader rdCer = new PemReader(trCer);

AsymmetricCipherKeyPair o = rdCer.ReadObject() as AsymmetricCipherKeyPair;

ISigner sig = SignerUtilities.GetSigner("MD5WithRSAEncryption");

sig.Init(true, o.Private);

sig.BlockUpdate(plaintext,0,plaintext.Length);

Byte[] signature  = sig.GenerateSignature();

string signatureHeader = Convert.ToBase64String(signature);

Console.WriteLine(signatureHeader);

How I can use a key in DER format? I'm using the library BouncyCastle.Crypto.dll

`