// hex 처리 예시 소스 (byte배열 받아서 string으로 리턴)
public String getHashHexString(byte[] hash) {
StringBuffer sb = new StringBuffer(hash.length * 2);
for (int i = 0; i < hash.length; i++) {
sb.append(Integer.toString((hash[i] & 0xf0) >> 4, 16));
sb.append(Integer.toString(hash[i] & 0x0f, 16));
}
return sb.toString();
}
// 원복 소스(다시 byte배열로 변환)
public static byte[] hexToByteArray(String hex) {
if (hex == null || hex.length() == 0) {
return null;
}
byte[] ba = new byte[hex.length() / 2];
for (int i = 0; i < ba.length; i++) {
ba[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
}
return ba;
}