private static String byteArrayToHexString(byte[] bytes){
  StringBuilder sb=new StringBuilder(bytes.length * 2);
  for (  byte element : bytes) {
    int v=element & 0xff;
    if (v < 16) {
      sb.append('0');
    }
    sb.append(Integer.toHexString(v));
  }
  return sb.toString();
}

private static String byteArrayToHexString ( byte [ ] bytes ) { StringBuilder sb = new StringBuilder ( bytes . length * 2 ) ; for ( byte element : bytes ) { int v = element & 0xff ; if ( v < 16 ) { sb . append ( '0' ) ; } sb . append ( Integer . toHexString ( v ) ) ; } return sb . toString ( ) ; }
using some super basic byte array & lt ; - & gt ; hex conversions so we don ' t have to rely on any large base64 libraries . can be overridden if you like !
