private static function toHex(bytes:ByteArray):String{
var pos:int =bytes.position;
bytes.position=0;
var result:String="";
while(bytes.bytesAvailable>=8){
result+=toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte())
+""+toHexNum(bytes.readUnsignedByte());
}
while(bytes.bytesAvailable>1){
result+=toHexNum(bytes.readUnsignedByte())+"";
}
if(bytes.bytesAvailable){
result+=toHexNum(bytes.readUnsignedByte());
}
bytes.position=pos;
return result;
}
private static function toHexNum(n:uint):String{
//return 0<0xF?" "+n.toString(16):n.toString(16);
return String.fromCharCode(n.toString());
}
posted on 2013-12-11 16:53  张海玉  阅读(402)  评论(0编辑  收藏  举报