I am using the following code to convert Hex to ASCII:
public String hexToAscii(String hex) {
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();
for(int i = 0; i < hex.length() - 1; i += 2){
String output = hex.substring(i, (i + 2));
int decimal = Integer.parseInt(output, 16);
sb.append((char)decimal);
temp.append(decimal);
}
return sb.toString();
}
Input:
hexToAscii("51d37bdd871c9e1f4d5541be67a6ab625e32028744d7d4609d0c37747b40cd2d");
Expected output:
QÓ{݇žMUA¾g¦«b^2‡D×Ô`7t{@Í-
Present output:
-Í@{t7?`Ô×D?2^b«¦g¾AUM??Ý{ÓQ.
Basically, the output I am getting is the reverse of the output that is expected. Any solutions?