[英]How to use key files in RSA Encryption using C#?
I Have given a file named publickey.key. 我给了一个名为publickey.key的文件。 It contains the following Text in it:
它包含以下文本:
脰ゟ؍⨉䢆čā脃脰ʉ膁딀쭡ﶅꐏ눜鎈㨾뵕匆裖奖閈㞉椼ɕ㈭㶕儐臐篙輌䡕㾜㩚a涨节鸝́붼낓蟰୧櫬瑇鋁슏ຐ궿䮹맥ӈ왶䤺ꚢ鑛靡⎞깳㌧꿛葧䋰��綧툻㳥핆ˣăĀ
I have some knowledge about RSA Encryption in c#. 我对c#中的RSA加密有一些了解。
It uses base-64 format for key, and some XML format for key file. 它对密钥使用base-64格式,对密钥文件使用某种XML格式。
But I really don't know, What is that format and How to use the given 'publickey.key' file that contains the above text. 但是我真的不知道,那是什么格式,以及如何使用包含上述文本的给定“ publickey.key”文件。
Please give me an idea on, 请给我一个想法,
Your file does not contain text. 您的文件不包含文本。 I guess you opened it with notepad and notepad decided it looked like Unicode and tried to decode it using that.
我想您是用记事本打开的,记事本决定它看起来像Unicode,并尝试使用它进行解码。
Actually your file contains ASN.1 encoded data. 实际上,您的文件包含ASN.1编码的数据。 The data was partially corrupted when written as text, so I cannot be sure what format it is, but it looks like a PKCS#8 structure with a PKCS#1 RSA public key inside.
以文本形式写入时,数据已部分损坏,因此我无法确定它是什么格式,但是它看起来像是内部带有PKCS#1 RSA公钥的PKCS#8结构。 You can decode it using BouncyCastle (
Org.BouncyCastle.Security.PublicKeyFactory.CreateKey()
) or a similar library. 您可以使用BouncyCastle(
Org.BouncyCastle.Security.PublicKeyFactory.CreateKey()
)或类似的库对其进行解码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.