Java Hex Calculate toHexString(byte[] data, int offset, int length)

Here you can find the source of toHexString(byte[] data, int offset, int length)

Description

to Hex String

License

Open Source License

Declaration

public static String toHexString(byte[] data, int offset, int length) 

Method Source Code

//package com.java2s;
/*/*from   ww  w  .ja va  2 s  .  c  o  m*/
 * Author   : Ardika Rommy Sanjaya
 * Website   : http://ardikars.com
 * Contact   : contact@ardikars.com
 * License   : Lesser GNU Public License Version 3
 */

public class Main {
    public static String toHexString(byte[] data, int offset, int length) {
        StringBuilder sb = new StringBuilder();
        int l;
        if (data.length != length) {
            l = data.length - length;
        } else {
            l = length;
        }
        for (int i = offset; i < l; i++) {
            sb.append(toHexString(data[i]));
        }
        return sb.toString();
    }

    public static String toHexString(byte b) {
        String s = Integer.toHexString((b) & 0xFF);
        if (s.length() == 1)
            return ("0" + s);
        return (s);
    }
}

Related

  1. toHexString(byte[] data)
  2. toHexString(byte[] data)
  3. toHexString(byte[] data)
  4. toHexString(byte[] data, final int offset, final int count)
  5. toHexString(byte[] data, int maxLen)
  6. toHexString(byte[] data, int offset, int length)
  7. toHexString(byte[] data, int start, int len)
  8. toHexString(byte[] data, int start, int length)
  9. toHexString(byte[] digest)