C# DES TCP加密
来源:互联网 发布:阿里云腾讯云对比性能 编辑:程序博客网 时间:2024/05/17 22:36
using System;using System.Text;using System.Windows.Forms;using System.Security.Cryptography;using System.IO;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } public byte[] Encrypt(string pToEncrypt) { byte[] rebyte; DESCryptoServiceProvider des = new DESCryptoServiceProvider(); byte[] inputByteArray = Encoding.Default.GetBytes(pToEncrypt); des.Key = new byte[] { 22, 85, 08, 13, 13, 15, 05, 38 }; des.IV = new byte[] { 22, 85, 08, 13, 13, 15, 05, 38 }; MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); rebyte = ms.ToArray(); return rebyte; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(Encoding.Default.GetString(Decrypt(Encrypt("我操")))); } public byte[] Decrypt(byte[] inputByteArray) { byte[] rebyte; DESCryptoServiceProvider des = new DESCryptoServiceProvider(); des.Key = new byte[] { 22, 85, 08, 13, 13, 15, 05, 38 }; des.IV = new byte[] { 22, 85, 08, 13, 13, 15, 05, 38 }; MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); rebyte = ms.ToArray(); return rebyte; } }}
将byte[]运用于socket即可
- C# DES TCP加密
- des加密(c#实现)
- des加密(c#实现)
- c# DES 加密解密
- c# des 加密解密
- DES 加密/解密-C#
- c# DES加密解密
- C#使用Des加密
- c# DES加密类
- C# DES 对称加密
- c# DES 加密解密
- C# DES加密
- c# des 加密 解密
- C# DES加密字符串
- DES加密 c++ C#
- C# 3DES 加密
- C# DES和3DES加密类
- C# DES加密/解密字符串
- c#除法中小数点的问题
- 嵌入式系统中的LCD调色板
- SomethingOn生产力提升工具使用
- dsp的gel文件认识
- 百度Android开发面试题
- C# DES TCP加密
- C语言程序的内存布局
- 真正认识 realloc 的工作方式。
- 解析xml
- 存储芯片的写屏蔽及扩展
- 关于c中的assert
- QoS队列调度算法概述
- u盘启动CDLINUX
- 掌握SDRAM/DDR的结构与寻址