Java Checksum Calculate checksumBytesToString(byte[] digestBytes)

Here you can find the source of checksumBytesToString(byte[] digestBytes)

Description

Converts a message digest byte array into a String based on the hex values appearing in the array.

License

Apache License

Declaration

public static String checksumBytesToString(byte[] digestBytes) 

Method Source Code

//package com.java2s;
/*// w w  w  .  j a  v  a 2  s. co  m
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 *     http://duracloud.org/license/
 */

public class Main {
    /**
     * Converts a message digest byte array into a String based
     * on the hex values appearing in the array.
     */
    public static String checksumBytesToString(byte[] digestBytes) {
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < digestBytes.length; i++) {
            String hex = Integer.toHexString(0xff & digestBytes[i]);
            if (hex.length() == 1) {
                hexString.append('0');
            }
            hexString.append(hex);
        }
        return hexString.toString();
    }
}

Related

  1. checksum(InputStream is)
  2. checksum(InputStream is)
  3. checksum(String filename)
  4. checksum(String nmea)
  5. checksum_icmpv6(byte pkt[])
  6. checksumFile(File file)
  7. checksumLength(int algorithmCode, int dataLength)
  8. createChecksum(File file, String shaAlgo)
  9. generateChecksum(InputStream is)