c#解密帮忙

vole007 2009-03-10 10:47:00
求大虾们帮忙看一下下面这个加密的程序的解密方式谢谢
private string ToHexString(byte[] bytes)
{
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7','8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
char[] chars = new char[bytes.Length * 2];
for (int i = 0; i < bytes.Length; i++)
{
int b = bytes[i];
chars[i * 2] = hexDigits[b >> 4];
chars[i * 2 + 1] = hexDigits[b & 0xF];
}
System.Console.Write("ret:" + new string(chars));
return new string(chars);
}
...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
vole007 2009-03-11
  • 打赏
  • 举报
回复
朋友上面那段代码测试结果为参数格式有问题
_ReturnBytes[i] = Convert.ToByte(_HexText.Substring(0, 2));
这里指向报异常
zgke 2009-03-10
  • 打赏
  • 举报
回复
这那里是加密啊 就是转换16进数字为字符


public byte[] ToByte(string p_HexString)
{
byte[] _ReturnBytes = new byte[p_HexString.Length / 2];

string _HexText = p_HexString;
for (int i = 0; i != _ReturnBytes.Length; i++)
{
_ReturnBytes[i] = Convert.ToByte(_HexText.Substring(0, 2));
_HexText = _HexText.Remove(0, 2);
}
return _ReturnBytes;
}

你想获取HEXSTRING没这么麻烦

public string ToHexText(byte[] p_Bytes)
{
return BitConverter.ToString(p_Bytes).ToUpper().Replace("-", "");
}

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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