Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am running into a very similar problem trying to create a native C# tool for packing Chrome extensions (using SHA1, not MD5, but that's not a big difference). I believe I have tried literally every possible solution for .Net: System.Security.Cryptography, BouncyCastle, OpenSSL.Net and Chilkat RSA. </p> <p>The best solution is probably Chilkat; their interface is the cleanest and most straightforward, it's well-supported and well-documented, and there are a million examples. For instance, here's some code using their library that does something very close to what you want: <a href="http://www.example-code.com/csharp/rsa_signPkcs8.asp" rel="nofollow noreferrer">http://www.example-code.com/csharp/rsa_signPkcs8.asp</a>. However, it's not free (though $150 is not unreasonable, seeing as I have burned 2 days trying to figure this out, and I make a bit more than $75 a day!).</p> <p>As a free alternative, JavaScience offers up a number of crypto utilities in source form for multiple languages (including C#/.Net) at <a href="http://www.jensign.com/JavaScience/cryptoutils/index.html" rel="nofollow noreferrer">http://www.jensign.com/JavaScience/cryptoutils/index.html</a>. The one that's most salient to what you are trying to do is opensslkey (<a href="http://www.jensign.com/opensslkey/index.html" rel="nofollow noreferrer">http://www.jensign.com/opensslkey/index.html</a>), which will let you generate a RSACryptoServiceProvider from a .pem file. You can then use that provider to sign your code:</p> <pre><code> string pemContents = new StreamReader("pkcs8privatekey.pem").ReadToEnd(); var der = opensslkey.DecodePkcs8PrivateKey(pemContents); RSACryptoServiceProvider rsa = opensslkey.DecodePrivateKeyInfo(der); signature = rsa.SignData(data, new MD5CryptoServiceProvider()); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload