开发者

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

开发者 https://www.devze.com 2023-04-06 23:27 出处:网络
I have a file testpublic.snk which holds a public key. I have created it with sn -p c:\\test.snk c:\\testpublic.snk.

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

精彩评论

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

关注公众号