开发者

How to convert a strongname public key (snk) to <RSAKeyValue>?

I have a file testpublic.snk which holds a public key. I have created it with sn -p c:\test.snk c:\testpublic.snk. Now, how can I convert testpublic.snk to a string like

<RSAKeyValue><Modulus>z140GwiEJvuGOVqMQUxnojILR8rn2SFOViigoloku59H5eqzqca3Hdyl/jc+Acdb5ktzhBOOyGFElE0/Btlvw9cXVVW8zcT0MBOCaq25D1rSVYLGGM6nXzBrl1XsrBEadZbCgkcF5rw8GaYcYakijaltP1/hvxhbMOARM9VCQ50=</Modulus><Ex开发者_C百科ponent>AQAB</Exponent></RSAKeyValue>

Thanks for your help.


Simply re-use the (MIT.X11 licensed) code from Mono.Security StrongName class, available in github, then call ToXmlString on it's RSA property. Something like:

Console.WriteLine (new StrongName (data).RSA.ToXmlString (false));

Where data is a byte[] containing the content of your snk file. Also you can use true if you want the private key in your XML (it will work if it was available fom your snk file).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜