Java Hex String Create appendHex(StringBuilder bld, byte b)

Here you can find the source of appendHex(StringBuilder bld, byte b)

Description

append Hex

License

Open Source License

Declaration

public static void appendHex(StringBuilder bld, byte b) 

Method Source Code

//package com.java2s;
/**/*w ww  .j av a 2 s  .c  o m*/
 * Copyright (c) 2013 Puppet Labs, Inc. and other contributors, as listed below.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Puppet Labs
 */

public class Main {
    private static final char[] hexChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f' };

    public static void appendHex(StringBuilder bld, byte b) {
        bld.append(hexChars[(b & 0xf0) >> 4]);
        bld.append(hexChars[b & 0x0f]);
    }

    public static void appendHex(StringBuilder bld, byte[] digest) {
        for (int idx = 0; idx < digest.length; ++idx)
            appendHex(bld, digest[idx]);
    }
}

Related

  1. appendHex(StringBuffer buffer, byte b)
  2. appendHex(StringBuffer buffer, int value)
  3. appendHex(StringBuffer sb, byte b)
  4. appendHex(StringBuffer sbuf, char ch)
  5. appendHex(StringBuffer stringbuffer, byte byte0)
  6. appendHex(StringBuilder buf, int value, int width)
  7. appendHex(StringBuilder buff, int i)
  8. appendHex(StringBuilder builder, int b)
  9. appendHexByte(byte b, StringBuffer buf)