Java Byte to Hex bytesToModHex(final byte[] inputBytes)

Here you can find the source of bytesToModHex(final byte[] inputBytes)

Description

bytes To Mod Hex

License

Open Source License

Declaration

public static String bytesToModHex(final byte[] inputBytes) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    private static final char[] MOD_HEX_DIGITS = { 'c', 'b', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'r',
            't', 'u', 'v' };

    public static String bytesToModHex(final byte[] inputBytes) {
        assert inputBytes != null;
        assert MOD_HEX_DIGITS != null;
        assert MOD_HEX_DIGITS.length == 16;
        StringBuilder modHexOutput = new StringBuilder(inputBytes.length * 2);
        for (byte b : inputBytes) {
            int msb = (b >> 4) & 0xf;
            int lsb = b & 0xf;
            assert msb >= 0;
            assert msb < MOD_HEX_DIGITS.length;
            assert lsb >= 0;
            assert lsb < MOD_HEX_DIGITS.length;
            modHexOutput.append(MOD_HEX_DIGITS[msb]);
            modHexOutput.append(MOD_HEX_DIGITS[lsb]);
        }//w w  w  .  j a va 2  s .  c  om
        return modHexOutput.toString();
    }
}

Related

  1. bytes2hex(byte[] bytes)
  2. Bytes2HexString(byte[] b)
  3. bytesToHex(byte b)
  4. bytesToHexs(byte[] buf)
  5. bytesToLowerCaseHex(byte[] data)
  6. bytesToPrettyHex(byte[] data)
  7. bytesToReadableHexStr(byte[] msg)
  8. bytesToUpperCaseHex(byte[] b)
  9. byteToHex(byte a)