.net rsa密钥转换为java的公钥,关于名为“将Java公钥密钥移植到C#.Net”的主题

I have read this topic, it''s wonderful.:thumbsup:

But I just have a reverse process about of this topic. The keys (public and private) were generated by .Net platform, I want to decode the public key to encrypt a text and then send it back to the .Net platform to decrypt it.

I can not convert the string of public key to Java public key. I have found many materials and it looks like the string of public key was generated with some random value by .Net platform.

What should I do with the string?

Thanks.

Below is the errors when I try to get the public key:Exception in thread "main" java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException: DerInputStream.getLength(): lengthTag=82, too big.

at sun.security.rsa.RSAKeyFactory.engineGeneratePublic(RSAKeyFactory.java:188)

at java.security.KeyFactory.generatePublic(KeyFactory.java:304)

at Test.main(Test.java:55)

Caused by: java.security.InvalidKeyException: IOException: DerInputStream.getLength(): lengthTag=82, too big.

at sun.security.x509.X509Key.decode(X509Key.java:380)

at sun.security.x509.X509Key.decode(X509Key.java:386)

at sun.security.rsa.RSAPublicKeyImpl.(RSAPublicKeyImpl.java:66)

at sun.security.rsa.RSAKeyFactory.generatePublic(RSAKeyFactory.java:281)

at sun.security.rsa.RSAKeyFactory.engineGeneratePublic(RSAKeyFactory.java:184)

... 2 more

解决方案

Don''t post this under Quick Answers - if you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them. If it is a topic in a forum, then the "Reply" link at the bottom of the topic does the same thing.

Posting this here relies on them "dropping by" and realising it is for them.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值