Here you can find the source of ascii2Hex(byte[] in)
public static byte[] ascii2Hex(byte[] in)
//package com.java2s; //License from project: Apache License public class Main { public static byte[] ascii2Hex(byte[] in) { byte[] temp1 = new byte[1]; byte[] temp2 = new byte[1]; int i = 0; byte[] out = new byte[in.length / 2]; for (int j = 0; i < in.length; j++) { temp1[0] = in[i];/*w w w . java 2 s .c o m*/ temp2[0] = in[(i + 1)]; if ((temp1[0] >= 48) && (temp1[0] <= 57)) { int tmp53_52 = 0; byte[] tmp53_51 = temp1; tmp53_51[tmp53_52] = (byte) (tmp53_51[tmp53_52] - 48); temp1[0] = (byte) (temp1[0] << 4); temp1[0] = (byte) (temp1[0] & 0xF0); } else if ((temp1[0] >= 97) && (temp1[0] <= 102)) { int tmp101_100 = 0; byte[] tmp101_99 = temp1; tmp101_99[tmp101_100] = (byte) (tmp101_99[tmp101_100] - 87); temp1[0] = (byte) (temp1[0] << 4); temp1[0] = (byte) (temp1[0] & 0xF0); } if ((temp2[0] >= 48) && (temp2[0] <= 57)) { int tmp149_148 = 0; byte[] tmp149_146 = temp2; tmp149_146[tmp149_148] = (byte) (tmp149_146[tmp149_148] - 48); temp2[0] = (byte) (temp2[0] & 0xF); } else if ((temp2[0] >= 97) && (temp2[0] <= 102)) { int tmp192_191 = 0; byte[] tmp192_189 = temp2; tmp192_189[tmp192_191] = (byte) (tmp192_189[tmp192_191] - 87); temp2[0] = (byte) (temp2[0] & 0xF); } out[j] = (byte) (temp1[0] | temp2[0]); i += 2; } return out; } }