最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
.NET中加密和解密的实现方法 3
时间:2022-07-02 12:15:42 编辑:袖梨 来源:一聚教程网
//使用客户端的公共密钥加密对称密钥并发送给客。
encryptAndSendSymmetricKey(client, rsa, symm);
//使用对称密钥加密信息并发送
encryptAndSendSecretMessage(client, symm, msg);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
finally
{
try
{
client.Close();
listener.Stop();
}
catch
{
//错误
}
Console.WriteLine("Server exiting...");
}
}
private static RSAParameters getClientPublicKey(TcpClient client)
{
// 从字节流获取串行化的公共密钥,通过串并转换写入类的实例
byte[] buffer = new byte[RSA_KEY_SIZE_BYTES];
NetworkStream ns = client.GetStream();
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
RSAParameters result;
int len = 0;
int totalLen = 0;
encryptAndSendSymmetricKey(client, rsa, symm);
//使用对称密钥加密信息并发送
encryptAndSendSecretMessage(client, symm, msg);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
finally
{
try
{
client.Close();
listener.Stop();
}
catch
{
//错误
}
Console.WriteLine("Server exiting...");
}
}
private static RSAParameters getClientPublicKey(TcpClient client)
{
// 从字节流获取串行化的公共密钥,通过串并转换写入类的实例
byte[] buffer = new byte[RSA_KEY_SIZE_BYTES];
NetworkStream ns = client.GetStream();
MemoryStream ms = new MemoryStream();
BinaryFormatter bf = new BinaryFormatter();
RSAParameters result;
int len = 0;
int totalLen = 0;
相关文章
- 光遇九色鹿季任务二攻略 九色鹿季第2个任务怎么做 12-05
- 珊瑚岛叶状海龙在哪 叶状海龙位置分享 12-05
- 星球重启伊甸城强敌坐标位置汇总 12-05
- 珊瑚岛巨花魔芋在哪 巨花魔芋刷新位置 12-05
- 魔兽世界怀旧服Plus猎人雄狮守护坐标及获取方法 12-05
- 珊瑚岛化石怎么获得 化石获得方式 12-05