预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共31页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

字符串转16进制字节数组 viewplaincopytoclipboardprint? privatestaticbyte[]strToToHexByte(stringhexString) { hexString=hexString.Replace("",""); if((hexString.Length%2)!=0) hexString+=""; byte[]returnBytes=newbyte[hexString.Length/2]; for(inti=0;i<returnBytes.Length;i++) returnBytes[i]=Convert.ToByte(hexString.Substring(i*2,2),16); returnreturnBytes; } privatestaticbyte[]strToToHexByte(stringhexString) { hexString=hexString.Replace("",""); if((hexString.Length%2)!=0) hexString+=""; byte[]returnBytes=newbyte[hexString.Length/2]; for(inti=0;i<returnBytes.Length;i++) returnBytes[i]=Convert.ToByte(hexString.Substring(i*2,2),16); returnreturnBytes; } 字节数组转16进制字符串 viewplaincopytoclipboardprint? publicstaticstringbyteToHexStr(byte[]bytes) { stringreturnStr=""; if(bytes!=null) { for(inti=0;i<bytes.Length;i++) { returnStr+=bytes[i].ToString("X2"); } } returnreturnStr; } publicstaticstringbyteToHexStr(byte[]bytes) { stringreturnStr=""; if(bytes!=null) { for(inti=0;i<bytes.Length;i++) { returnStr+=bytes[i].ToString("X2"); } } returnreturnStr; } 从汉字转换到16进制 viewplaincopytoclipboardprint? publicstaticstringToHex(strings,stringcharset,boolfenge) { if((s.Length%2)!=0) { s+="";//空格 //thrownewArgumentException("sisnotvalidchinesestring!"); } System.Text.Encodingchs=System.Text.Encoding.GetEncoding(charset); byte[]bytes=chs.GetBytes(s); stringstr=""; for(inti=0;i<bytes.Length;i++) { str+=string.Format("{0:X}",bytes[i]); if(fenge&&(i!=bytes.Length-1)) { str+=string.Format("{0}",","); } } returnstr.ToLower(); } publicstaticstringToHex(strings,stringcharset,boolfenge) { if((s.Length%2)!=0) { s+="";//空格 //thrownewArgumentException("sisnotvalidchinesestring!"); } System.Text.Encodingchs=System.Text.Encoding.GetEncoding(charset); byte[]bytes=chs.GetBytes(s); stringstr=""; for(inti=0;i<bytes.Length;i++) { str+=string.Format("{0:X}",bytes[i]); if(fenge&&(i!=bytes.Length-1)) { str+=string.Format("{0}",","); } } returnstr.ToLower(); } 从16进制转换成汉字 viewplaincopytoclipboardprint? publicstaticstringUnHe