Java Hex Calculate toHexString(byte[] digest)

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

Description

byte to hex

License

Apache License

Parameter

Parameter Description
digest a parameter

Declaration

private static String toHexString(byte[] digest) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from w  w  w . j  a  va2 s  .c o m
     * byte to hex
     * @param digest
     * @return
     */
    private static String toHexString(byte[] digest) {
        String str = "";
        String tempStr = "";
        for (int i = 0; i < digest.length; i++) {
            tempStr = (Integer.toHexString(digest[i] & 0xff));
            if (tempStr.length() == 1)
                str = str + "0" + tempStr;
            else
                str = str + tempStr;
        }
        return str.toLowerCase();
    }
}

Related

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