Java Hex Calculate toHex(byte hash[])

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

Description

to Hex

License

Open Source License

Declaration

private static final String toHex(byte hash[]) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String toHex(byte hash[]) {
        if (hash == null) {
            return null;
        }/*  www .  jav  a 2s.  co  m*/
        StringBuffer buf = new StringBuffer(hash.length * 2);
        int i;

        for (i = 0; i < hash.length; i++) {
            if ((hash[i] & 0xff) < 0x10) {
                buf.append("0");
            }
            buf.append(Long.toString(hash[i] & 0xff, 16));
        }
        return buf.toString();
    }
}

Related

  1. toHex(byte b)
  2. toHex(byte b, char[] charArray, int from)
  3. toHex(byte b, String prefix)
  4. toHex(byte bytes[])
  5. toHex(byte data[])
  6. toHex(byte in)
  7. toHex(byte in[])
  8. toHex(byte in[])
  9. toHex(byte input[])