客户端加密服务器端解密文件,RSA(客户端加密/服务器解密)

这是此question项目的延续,但没有Bouncy城​​堡。

所以我决定废弃Bouncy Castle(可惜,我喜欢这个名字)

ANYWAY

我有一台服务器和一台客户端。客户端需要将序列化对象发送到服务器,然后服务器将处理该对象。

这样做,但是我想在流程中添加加密功能。但是没有存储文件或类似的东西。该过程需要基于会话(在某种意义上)

因此,客户端将从服务器请求密钥,服务器将生成密钥对并将密钥发送给客户端。

客户端然后使用此密钥加密对象

string key = ASCIIEncoding.ASCII.GetString(RequestKey(tcpclnt));

var RsaClient =new RSACryptoServiceProvider(2048);

while (key.Length > 0) {

RsaClient.FromXmlString(key);

var transmit = ASCIIEncoding.ASCII.GetBytes(stringtosend);

var encrypted = RsaClient.Encrypt(transmit,false);

服务器然后接收这些加密的字节并尝试解密它们

raw = Receive(clientSocket);

byte[] r = TrimBytes(ASCIIEncoding.ASCII.GetBytes(raw),256);

var sdecrypted = ASCIIEncoding.ASCII.GetString(RsaServer.Decrypt(r, false));

但是,唉,服务器无法做到这一点。在解密时会抛出错误

Key does not exist.

所以,我的问题是,我做错了什么?

非常感谢您提供的任何帮助。

更新

修改服务器中的代码

var RSAKeyInfo = new RSACryptoServiceProvider(2048, new CspParameters(1)).ExportParameters(true);

新错误

The parameter is incorrect

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
千年封包解密库 MICROSOFT FOUNDATION CLASS LIBRARY : SubPacket AppWizard has created this SubPacket application for you. This application not only demonstrates the basics of using the Microsoft Foundation classes but is also a starting point for writing your application. This file contains a summary of what you will find in each of the files that make up your SubPacket application. SubPacket.dsp This file (the project file) contains information at the project level and is used to build a single project or subproject. Other users can share the project (.dsp) file, but they should export the makefiles locally. SubPacket.h This is the main header file for the application. It includes other project specific headers (including Resource.h) and declares the CSubPacketApp application class. SubPacket.cpp This is the main application source file that contains the application class CSubPacketApp. SubPacket.rc This is a listing of all of the Microsoft Windows resources that the program uses. It includes the icons, bitmaps, and cursors that are stored in the RES subdirectory. This file can be directly edited in Microsoft Visual C++. SubPacket.clw This file contains information used by ClassWizard to edit existing classes or add new classes. ClassWizard also uses this file to store information needed to create and edit message maps and dialog data maps and to create prototype member functions. resSubPacket.ico This is an icon file, which is used as the application s icon. This icon is included by the main resource file SubPacket.rc. resSubPacket.rc2 This file contains resources that are not edited by Microsoft Visual C++. You should place all resources not editable by the resource editor in this file. AppWizard creates one dialog class: SubPacketDlg.h, SubPacketDlg.cpp - the dialog These files contain your CSubPacketDlg class. This class defines the be

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值