加密程序是用C#编写的,但解密是用java编写的

编程入门 行业动态 更新时间:2024-10-23 21:32:51
本文介绍了加密程序是用C#编写的,但解密是用java编写的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个问题,而且很多天都在挣扎 下面的代码我需要在公共.cer文件中加密c#

string encrytedText; SKey1 = aem.Key; string CERTFPATH = ConfigurationManager.AppSettings [ UIDAIPublicCertificate]的ToString(); X509Certificate2 uidCert = new X509Certificate2(CERTFPATH, public,X509KeyStorageFlags.DefaultKeySet); RSACryptoServiceProvider RSA =(RSACryptoServiceProvider)uidCert.PublicKey.Key; { RSAParameters RSAKeyInfo = RSA.ExportParameters( false ); encrytedText = Convert.ToBase64String(RSA.Encrypt(SKey1, false )); } return encrytedText;

i将上面生成的加密文本传递给第三方创建的java api,它没有在java api上正确解密结束 有人可以帮助我们吗? 我尝试了什么: 来自搜索,我得到了参考,因为你可以使用充气城堡,但我有代码,我可以使用有2058密钥长度的公共证书来加密它

解决方案

你需要做的第一件事就是找出问题所在。 所以用C#加密它,然后写代码解密它在C#中。 如果结果与输入相同,请继续进行下一次检查:它是否正在转移?检查Java代码将根据C#的输出解密的数据。它是一样的吗?如果是这样,接下来检查一下:Java做了什么?编写Java代码来加密原始材料。编写代码来解密它。输出是否与输入相同?如果是,则将Java的加密输出与C#加密的输出进行比较。它们是一样的吗? 在某些时候,你会发现一个不同之处。然后你可以专注于为什么。但是直到你知道问题出在哪里,你只是在黑暗中吹口哨。

我使用

RijndaelManaged managed = new RijndaelManaged();

加密类然后我的这个问题已经解决了, 如果有人需要示例代码,请发邮件给我个人vipul.ghadge@gmail

hi, I have this problem , and being struggling lots of days Below code i have for encryption in c# from public .cer file

string encrytedText; SKey1 = aem.Key; string CERTFPATH = ConfigurationManager.AppSettings["UIDAIPublicCertificate"].ToString(); X509Certificate2 uidCert = new X509Certificate2(CERTFPATH, "public", X509KeyStorageFlags.DefaultKeySet); RSACryptoServiceProvider RSA = (RSACryptoServiceProvider)uidCert.PublicKey.Key; { RSAParameters RSAKeyInfo = RSA.ExportParameters(false); encrytedText = Convert.ToBase64String(RSA.Encrypt(SKey1, false)); } return encrytedText;

i pass above generated encrypted text to java api create by third party , it doesn't getting properly decrypted at java api end could anybody help us ? What I have tried: from search , i got references as you can use bouncy Castle , but i havnt got code where i can use public certificate which has 2058 key length to encrypt it

解决方案

The first thing you need to do is find out where the problem is. So encrypt it in C#, then write code to decrypt it in C#. If the result is the same as the input, move on to the next check: it is getting transferred ok? Check the data the Java code is going to decrypt against the output of the C#. Is it identical? If so, next check: what does the Java do? Write Java code to encrypt the original material. Write code to decrypt it. Is the output the same as the input? If it is, compare the encrypted output from the Java with the output from the C# encryption. Are they the same? At some point, you'll find a difference. Then you can concentrate on why. But until you know where the problem starts, you are just whistling in the dark.

I have use

RijndaelManaged managed = new RijndaelManaged();

class for encryption then my this issue has resolved , if any one need sample code , mail me i will provide in personal vipul.ghadge@gmail

更多推荐

加密程序是用C#编写的,但解密是用java编写的

本文发布于:2023-11-05 12:38:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!