开发者

How to use key files in RSA Encryption using C#?

开发者 https://www.devze.com 2023-03-23 13:50 出处:网络
I Have given a file named publickey.key. It contains the following Text in it: 脰ゟ؍⨉䢆čā脃脰ʉ膁딀쭡ﶅꐏ눜鎈㨾뵕匆裖奖閈㞉椼ɕ㈭㶕儐臐篙輌䡕㾜㩚᝿a涨节鸝́붼낓蟰୧櫬瑇鋁슏ຐ궿䮹맥ӈ왶䤺

I Have given a file named publickey.key. It contains the following Text in it:

脰ゟ؍⨉䢆čā脃脰ʉ膁딀쭡ﶅꐏ눜鎈㨾뵕匆裖奖閈㞉椼ɕ㈭㶕儐臐篙輌䡕㾜㩚᝿a涨节鸝́붼낓蟰୧櫬瑇鋁슏ຐ궿䮹맥ӈ왶䤺ꚢ鑛靡⎞깳㌧꿛葧䋰��綧툻㳥핆ˣăĀ

I have some knowledge about RSA Encryption in c#.

It uses base-64 format for 开发者_如何学Gokey, and some XML format for key file.

But I really don't know, What is that format and How to use the given 'publickey.key' file that contains the above text.

Please give me an idea on,

  1. How to encrypt some text using that publickey.key file?
  2. I have privatekey.key file too which has some text of similar kind shown above, How can I need to decrypt the encrypted file using that?


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.

Actually your file contains ASN.1 encoded data. 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. You can decode it using BouncyCastle (Org.BouncyCastle.Security.PublicKeyFactory.CreateKey()) or a similar library.

0

精彩评论

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

关注公众号