自己制作的加密解密程序。。。

net_jian 2006-09-08 10:59:04
因公司需要一个自己制作的加密程序,要求能解密,以便方便BS交易然后CS解析.
问一下大虾们,如何取得键盘上任一键的ASCI码,然后再根据ASCI码返回键盘值?
如果你们有别的设计方法,希望能够大家一起探讨。
...全文
236 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiejun20 2007-03-21
  • 打赏
  • 举报
回复
再加个命名空间
using System.Security
sunjay117 2006-09-08
  • 打赏
  • 举报
回复
using System.Security.Cryptography;
using System.IO;
using System.Text;
net_jian 2006-09-08
  • 打赏
  • 举报
回复
这个我加了,还少一个。
avisnet 2006-09-08
  • 打赏
  • 举报
回复
System.Security.Cryptography
net_jian 2006-09-08
  • 打赏
  • 举报
回复
来个人顶啊~
net_jian 2006-09-08
  • 打赏
  • 举报
回复
大哥,上面的程序需要哪些命名空间啊~
sunjay117 2006-09-08
  • 打赏
  • 举报
回复
public static String Encrypt(String strText)
{
Byte[] byKey = {};
Byte[] IV = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(Enum.EncryptText.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch(Exception ex)
{
return ex.Message;
}
}
public static String Decrypt(String strText)
{
Byte[] byKey = {};
Byte[] IV = {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF};
Byte[] inputByteArray = new byte[strText.Length];
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(Enum.EncryptText.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch(Exception ex)
{
return ex.Message;
}
}
sportdog 2006-09-08
  • 打赏
  • 举报
回复
错误错误~怎么来的都是菜鸟。

------------------
晕,....
会也不说了!
net_jian 2006-09-08
  • 打赏
  • 举报
回复
错误错误~怎么来的都是菜鸟。

62,042

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧