File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed 
src/test/java/top/meethigher/proxy Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -174,4 +174,29 @@ private WriteException(Throwable cause) {
174174            super (cause , true );
175175        }
176176    }
177+ 
178+     /** 
179+      * 转换为八进制字符串 
180+      * Wireshark默认抓包时,使用的就是八进制字符串 
181+      */ 
182+     private  static  String  toOctString (byte [] buf ) {
183+         StringBuilder  sb  = new  StringBuilder ();
184+         for  (byte  value  : buf ) {
185+             int  b  = value  & 0xFF ;// 转为无符号字节 
186+             sb .append (String .format ("%03o " , b ));// ddd格式。每个d表示一个0-7的数字 
187+         }
188+         return  sb .toString ();
189+     }
190+ 
191+     /** 
192+      * 转换为16进制字符串 
193+      */ 
194+     private  static  String  toHexString (byte [] buf ) {
195+         StringBuilder  sb  = new  StringBuilder ();
196+         for  (byte  value  : buf ) {
197+             int  b  = value  & 0xFF ;//转为无符号字节 
198+             sb .append (String .format ("%02x " , b ));// 两位十六进制,不足补0 
199+         }
200+         return  sb .toString ();
201+     }
177202}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments