Try this function from my library out. You do not do any calculation with this function. Only string compare, and you can convert as much binary to hexadecimal as you like. As long as the limitation on how long a string can be.
public static String binhexZ(String input)
{
String map = "0000,0,0001,1,0010,2,0011,3,0100,4,0101,5,0110,6,0111,7,1000,8,1001,9,1010,A,1011,B,1100,C,1101,D,1110,E,1111,F";
String output = "";
int i = 0;
while (input.length() % 4 != 0){
input = "0" + input;
}
while (i < input.length()){
output += map.charAt(map.indexOf(input.substring(i, i + 4)) + 5);
i = i + 4;
}
output = output.replaceAll("^0+", "");
output = output.length() < 1? "0" : output;
return output;
}