Android Hex String Create encodeHex(byte[] pData)

Here you can find the source of encodeHex(byte[] pData)

Description

encode Hex

License

Open Source License

Declaration

private static String encodeHex(byte[] pData) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };

    private static String encodeHex(byte[] pData) {
        int l = pData.length;

        char[] out = new char[l << 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; i < l; i++) {
            out[j++] = DIGITS[(0xF0 & pData[i]) >>> 4];
            out[j++] = DIGITS[0x0F & pData[i]];
        }//from w  w  w .  j  a  va2  s  .c o  m

        return new String(out);
    }
}

Related

  1. convertToHex(byte[] data)
  2. byte2HexStr(byte[] b, int length)
  3. byte2hex(byte[] bytes)
  4. bytesToHex(byte[] bytes)
  5. encodeHex(byte[] bytes)
  6. hex(int value, int digits)
  7. hexCharToInt(char c)
  8. hexDecode(String str, byte[] ba, int len)
  9. hexEncode(byte[] aInput)