All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.payneteasy.websocket.HexUtil Maven / Gradle / Ivy

There is a newer version: 1.0-8
Show newest version
package com.payneteasy.websocket;

public class HexUtil {

    private static final char[] CHARS_TABLES = "0123456789ABCDEF".toCharArray();
    protected static final byte[] BYTES = new byte[128];

    static {
        for(int i=0; i>> 4] );
            sb.append( CHARS_TABLES[(b & 0x0f)] );

        }

        return sb.toString();

    }

    public static String toHexString(byte[] aBytes, int aOffset, int aLength) {
        char[] dst   = new char[aLength * 2];

        for (int si = aOffset, di = 0; si < aOffset+aLength; si++) {
            byte b = aBytes[si];
            dst[di++] = CHARS_TABLES[(b & 0xf0) >>> 4];
            dst[di++] = CHARS_TABLES[(b & 0x0f)];
        }

        return new String(dst);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy