package de.rtner.misc;

public class BinTools {
public static final String hex = "0123456789ABCDEF"; public BinTools() {
super();
} public static String bin2hex(byte[] arg5) {
String v0;
if(arg5 == null) {
v0 = "";
}
else {
StringBuffer v1 = new StringBuffer(arg5.length * );
int v0_1;
for(v0_1 = ; v0_1 < arg5.length; ++v0_1) {
int v2 = (arg5[v0_1] + ) % ;
v1.append("0123456789ABCDEF".charAt(v2 / & ));
v1.append("0123456789ABCDEF".charAt(v2 % & ));
} v0 = v1.toString();
} return v0;
} public static int hex2bin(char arg3) {
int v0;
if(arg3 < || arg3 > ) {
if(arg3 >= && arg3 <= ) {
return arg3 - ;
} if(arg3 >= && arg3 <= ) {
return arg3 - ;
} goto label_20;
}
else {
v0 = arg3 - ;
} return v0;
label_20:
throw new IllegalArgumentException(new StringBuffer().append("Input string may only contain hex digits, but found \'")
.append(arg3).append("\'").toString());
} public static byte[] hex2bin(String arg5) {
int v0 = ;
if(arg5 == null) {
arg5 = "";
}
else if(arg5.length() % != ) {
arg5 = new StringBuffer().append("").append(arg5).toString();
} byte[] v2 = new byte[arg5.length() / ];
int v1 = ;
while(v1 < arg5.length()) {
int v3 = v1 + ;
char v4 = arg5.charAt(v1);
v1 = v3 + ;
v2[v0] = ((byte)(BinTools.hex2bin(arg5.charAt(v3)) + BinTools.hex2bin(v4) * ));
++v0;
} return v2;
} public static void main(String[] arg5) {
int v4 = ;
int v0 = ;
byte[] v3 = new byte[v4];
byte v1;
for(v1 = ; v0 < v4; v1 = ((byte)(v1 + ))) {
v3[v0] = v1;
++v0;
} String v0_1 = BinTools.bin2hex(v3);
if(!v0_1.equals(BinTools.bin2hex(BinTools.hex2bin(v0_1)))) {
throw new AssertionError("Mismatch");
}
}
}
04-24 14:53