Java Hex Calculate toHexString(byte[] byteDigest)

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

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] byteDigest) 

Method Source Code

//package com.java2s;

public class Main {
    public static String toHexString(byte[] byteDigest) {
        String temp = "";
        int i, len = byteDigest.length;
        for (i = 0; i < len; i++) {
            String byteString = Integer.toHexString(byteDigest[i]);

            int iniIndex = byteString.length();
            if (iniIndex == 2)
                temp = temp + byteString;
            else if (iniIndex == 1)
                temp = temp + "0" + byteString;
            else if (iniIndex == 0)
                temp = temp + "00";
            else if (iniIndex > 2)
                temp = temp + byteString.substring(iniIndex - 2, iniIndex);
        }//from  www .j a v  a 2s .  c  om
        return temp;
    }
}

Related

  1. toHexString(byte[] byteArray)
  2. toHexString(byte[] byteArray)
  3. toHexString(byte[] byteArray, boolean withSpaces)
  4. toHexString(byte[] byteArray, int offset, int size)
  5. toHexString(byte[] byteArray, String delim)
  6. toHexString(byte[] bytes)
  7. toHexString(byte[] bytes)
  8. toHexString(byte[] bytes)
  9. toHexString(byte[] bytes)