Java Hex Calculate toHexString(byte[] digestByte)

Here you can find the source of toHexString(byte[] digestByte)

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] digestByte) 

Method Source Code

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

public class Main {
    public static String toHexString(byte[] digestByte) {
        return new String(toHex(digestByte));
    }/*from   w  ww.  j  a v  a  2s  .  c  om*/

    public static byte[] toHex(byte[] digestByte) {
        byte[] rtChar = new byte[digestByte.length * 2];
        for (int i = 0; i < digestByte.length; i++) {
            byte b1 = (byte) (digestByte[i] >> 4 & 0x0f);
            byte b2 = (byte) (digestByte[i] & 0x0f);
            rtChar[i * 2] = (byte) (b1 < 10 ? b1 + 48 : b1 + 55);
            rtChar[i * 2 + 1] = (byte) (b2 < 10 ? b2 + 48 : b2 + 55);
        }
        return rtChar;
    }
}

Related

  1. toHexString(byte[] data, int start, int len)
  2. toHexString(byte[] data, int start, int length)
  3. toHexString(byte[] digest)
  4. toHexString(byte[] digest)
  5. toHexString(byte[] digest)
  6. toHexString(byte[] in)
  7. toHexString(byte[] input)
  8. toHexString(byte[] md)
  9. toHexString(byte[] messagePayload)