关于名为“将Java公钥散列移植到C#.Net"的主题 [英] About the topic called 'Porting Java Public Key Hash to C# .Net'

查看:89
本文介绍了关于名为“将Java公钥散列移植到C#.Net"的主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了这个主题,很棒.:thumbsup:

但是关于这个话题我只是一个相反的过程.密钥(公共密钥和私有密钥)是由.Net平台生成的,我想对公共密钥进行解码以对文本进行加密,然后将其发送回.Net平台以对其进行解密.

我无法将公共密钥的字符串转换为Java公共密钥.我发现了很多材料,而且看起来好像.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.<init>(RSAPublicKeyImpl.java:66)
	at sun.security.rsa.RSAKeyFactory.generatePublic(RSAKeyFactory.java:281)
	at sun.security.rsa.RSAKeyFactory.engineGeneratePublic(RSAKeyFactory.java:184)
	... 2 more</init>

推荐答案

不要将其发布在快速解答"下-如果您从文章中获得了代码,则在该文章的底部,这将导致向作者发送电子邮件.然后,他们会收到警报,告知您希望与他们交谈.如果它是论坛中的主题,则该主题底部的答复"链接将执行相同的操作.
将其发布到此处依赖于他们的下落"并意识到它是针对他们的.
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.


这篇关于关于名为“将Java公钥散列移植到C#.Net"的主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆