Java Hex Calculate toHexChar(byte[] bArray)

Here you can find the source of toHexChar(byte[] bArray)

Description

to Hex Char

License

Open Source License

Declaration

public static char[] toHexChar(byte[] bArray) 

Method Source Code

//package com.java2s;
/* /*w  w  w  . java  2 s.c  o  m*/
 * @(#)StringUtil.java 1.0 2004-10-11
 *
 * Copyright 2005 UFIDA Software Co. Ltd. All rights reserved.
 * UFIDA PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {

    public static char[] toHexChar(byte[] bArray) {
        char[] digitChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
        char[] charDigest = new char[bArray.length * 2];

        for (int i = 0; i < bArray.length; i++) {
            charDigest[i * 2] = digitChars[(bArray[i] >>> 4) & 0X0F];
            charDigest[i * 2 + 1] = digitChars[bArray[i] & 0X0F];
        }
        return charDigest;
    }
}

Related

  1. toHexByte(int i)
  2. toHexByteArray(final byte[] buffer)
  3. toHexBytes(byte[] bytes)
  4. toHexBytes(byte[] data)
  5. toHexBytes(byte[] toBeConverted)
  6. toHexChar(char ch, StringBuffer sb)
  7. toHexChar(int b)
  8. toHexChar(int digit)
  9. toHexChar(int digitValue)