日期:2014-05-18 浏览次数:20983 次
str = str.Substring(2);
byte[] bytes = new byte[str.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = Convert.ToByte(str.Substring(i * 2, 2), 16);
}
------解决方案--------------------
string s="";
byte[] b= System.Text.Encoding.BigEndianUnicode.GetBytes(s);
s=BitConverter.ToString(b).Replace("-","");
MessageBox.Show(s);
public static string GetChsFromHex(string hex)
{
byte[] bytes = new byte[hex.Length / 2];
for (int i = 0; i < bytes.Length; i++)
{
try
{
bytes[i] = byte.Parse(hex.Substring(i * 2, 2),
System.Globalization.NumberStyles.HexNumber);
}
catch
{
}
}
System.Text.Encoding chs = System.Text.Encoding.GetEncoding("gb2312");
return chs.GetString(bytes);
}
------解决方案--------------------
这个只能试这分析 因为一段代码 可以有n种不同方式加密
------解决方案--------------------
你都没说明要解码到什么类型上,这段内容很可能是某个对象序列化后的二进制内容,也可能是直接字符串编码后的内容,甚至还可能加过密,你什么都不交代,叫别人怎么处理二进制?
------解决方案--------------------
你需要先知道存进去的是什么才能找到正确的解码方法。一般情况下使用GetBytes就可以,但目前从结果看,存的内容是经过处理的,或者存入 的是文件