Java Hex Calculate toHex(byte[] src)

Here you can find the source of toHex(byte[] src)

Description

to Hex

License

Open Source License

Declaration

public static byte[] toHex(byte[] src) 

Method Source Code

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

public class Main {
    private final static byte[] CHEX = { '0', '1', '2', '3', '4', '5', '6',
            '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

    public static byte[] toHex(byte[] src) {
        int l = src.length;
        byte dst[] = new byte[l * 2];
        for (int i = 0, j = 0; i < l; i++) {
            int k = src[i];
            k &= (int) 0xFF;
            dst[j++] = CHEX[k >> 4];
            dst[j++] = CHEX[k & 0x0F];
        }//from   w ww.  ja va  2  s . co  m
        return dst;
    }
}

Related

  1. toHex(byte[] key)
  2. toHex(byte[] raw)
  3. toHex(byte[] raw)
  4. toHex(byte[] raw)
  5. ToHex(byte[] src)
  6. toHex(byte[] text)
  7. toHex(byte[] v)
  8. toHex(byte[] val)
  9. toHex(byte[] val, int start, int len)