Package De.rtner.misc; Public classBintools { Public StaticFinal String hex ="0123456789ABCDEF"; PublicBintools () {super (); } Public StaticString Bin2Hex (byte[] arg5) {String v0; if(Arg5 = =NULL) {V0=""; } Else{StringBuffer v1=NewStringBuffer (Arg5.length *2); intv0_1; for(V0_1 =0; V0_1 < Arg5.length; ++v0_1) { intV2 = (Arg5[v0_1] + the) % the; V1.append ("0123456789ABCDEF". CharAt (V2/ -& the)); V1.append ("0123456789ABCDEF". charAt (v2% -& the)); } v0=v1.tostring (); } returnV0; } Public Static intHex2bin (CharArg3) { intV0; if(Arg3 < -|| Arg3 > $) { if(Arg3 >= $&& Arg3 <= -) { returnArg3- -; } if(Arg3 >= the&& Arg3 <=102) { returnArg3- the; } Gotolabel_20; } Else{v0= Arg3- -; } returnV0; LABEL_20:Throw NewIllegalArgumentException (NewStringBuffer (). Append ("Input string contain hex digits, but found \ '"). Append (Arg3). Append ("\ '"). toString ()); } Public Static byte[] Hex2bin (String arg5) {intV0 =0; if(Arg5 = =NULL) {Arg5=""; } Else if(Arg5.length ()%2!=0) {Arg5=NewStringBuffer (). Append ("0"). Append (Arg5). toString (); } byte[] v2 =New byte[Arg5.length ()/2]; intV1 =0; while(V1 <arg5.length ()) { intV3 = v1 +1; CharV4 =Arg5.charat (v1); V1= V3 +1; V2[v0]= ((byte) (Bintools.hex2bin (Arg5.charat (v3)) + bintools.hex2bin (v4) * -)); ++V0; } returnv2; } Public Static voidMain (string[] arg5) {intV4 = the; intV0 =0; byte[] V3 =New byte[V4]; bytev1; for(V1 =0; V0 < V4; V1 = ((byte) (V1 +1)) {V3[v0]=v1; ++V0; } String v0_1=Bintools.bin2hex (v3); if(!v0_1.equals (Bintools.bin2hex (Bintools.hex2bin (v0_1))) { Throw NewAssertionerror ("mismatch"); } }}
Bintools 16 Binary Conversion