Hexadecimal representation containing digits (0-9) with upper-case letters (A-F)
@return Hexadecimal encoded string
975340
public String asHex() throws IOException {
        byte[] bytes = asByteArray();
        char[] hex = new char[bytes.length * 2];
        for ( int j = 0; j < bytes.length; j++ ) {
            int v = bytes[j] & 0xFF;
            hex[j * 2] = HEX_ARRAY[v >>> 4];
            hex[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
        }
        return new String(hex);
    }
1324849
public static String toHexString(final PublicKey publicKey, final boolean lowerCase)
	{
		return HexExtensions.toHexString(publicKey.getEncoded(), lowerCase);
	}
788360
private static String upperCaseHex(String s) {
        char chars[] = s.toCharArray();
        int length = s.length();

        for (int i = 0; i < length; i++) {

            switch (chars[i]) {
                case 'a':
                    chars[i] = 'A';
                    break;
                case 'b':
                    chars[i] = 'B';
                    break;
                case 'c':
                    chars[i] = 'C';
                    break;
                case 'd':
                    chars[i] = 'D';
                    break;
                case 'e':
                    chars[i] = 'E';
                    break;
                case 'f':
                    chars[i] = 'F';
                    break;
            }
        }

        return new String(chars);
    }
123062
private function hex16(){
        $val = dechex(floor((1 + ((float)rand()/(float)getrandmax())) * 0x10000));
        return substr($val,0,-1);
    }
658911
private String getIdAsString() {
        String id = Long.toHexString(getId()).toUpperCase();

        // Somewhat inefficient, but it won't happen that often
        // because an ID is often a big integer.
        while (id.length() < 8) {
            id = '0' + id; // padding
        }
        id = "0x" + id;

        return id;
    }
1233727
public function getBytes()
    {
        $bytes = '';

        foreach (range(-2, -32, 2) as $step) {
            $bytes = chr(hexdec(substr($this->getHex(), $step, 2))) . $bytes;
        }

        return $bytes;
    }
907839
private int getAndParseHexChar() throws ParseException {
        final char hexChar = getc();
        if (hexChar >= '0' && hexChar <= '9') {
            return hexChar - '0';
        } else if (hexChar >= 'a' && hexChar <= 'f') {
            return hexChar - 'a' + 10;
        } else if (hexChar >= 'A' && hexChar <= 'F') {
            return hexChar - 'A' + 10;
        } else {
            throw new ParseException(this, "Invalid character in Unicode escape sequence: " + hexChar);
        }
    }
1324810
public AsciiString toUpperCase() {
        boolean uppercased = true;
        int i, j;
        final int len = length() + arrayOffset();
        for (i = arrayOffset(); i < len; ++i) {
            byte b = value[i];
            if (b >= 'a' && b <= 'z') {
                uppercased = false;
                break;
            }
        }

        // Check if this string does not contain any lowercase characters.
        if (uppercased) {
            return this;
        }

        final byte[] newValue = PlatformDependent.allocateUninitializedArray(length());
        for (i = 0, j = arrayOffset(); i < newValue.length; ++i, ++j) {
            newValue[i] = toUpperCase(value[j]);
        }

        return new AsciiString(newValue, false);
    }
441564
private String _encode(long... numbers) {
        long numberHashInt = 0;
        for (int i = 0; i < numbers.length; i++) {
            numberHashInt += (numbers[i] % (i + 100));
        }
        String     alphabet = this.alphabet;
        final char ret      = alphabet.charAt((int) (numberHashInt % alphabet.length()));

        long                num;
        long                sepsIndex, guardIndex;
        String              buffer;
        final StringBuilder ret_strB = new StringBuilder(this.minHashLength);
        ret_strB.append(ret);
        char guard;

        for (int i = 0; i < numbers.length; i++) {
            num = numbers[i];
            buffer = ret + this.salt + alphabet;

            alphabet = Hashids.consistentShuffle(alphabet, buffer.substring(0, alphabet.length()));
            final String last = Hashids.hash(num, alphabet);

            ret_strB.append(last);

            if (i + 1 < numbers.length) {
                if (last.length() > 0) {
                    num %= (last.charAt(0) + i);
                    sepsIndex = (int) (num % this.seps.length());
                } else {
                    sepsIndex = 0;
                }
                ret_strB.append(this.seps.charAt((int) sepsIndex));
            }
        }

        String ret_str = ret_strB.toString();
        if (ret_str.length() < this.minHashLength) {
            guardIndex = (numberHashInt + (ret_str.charAt(0))) % this.guards.length();
            guard = this.guards.charAt((int) guardIndex);

            ret_str = guard + ret_str;

            if (ret_str.length() < this.minHashLength) {
                guardIndex = (numberHashInt + (ret_str.charAt(2))) % this.guards.length();
                guard = this.guards.charAt((int) guardIndex);

                ret_str += guard;
            }
        }

        final int halfLen = alphabet.length() / 2;
        while (ret_str.length() < this.minHashLength) {
            alphabet = Hashids.consistentShuffle(alphabet, alphabet);
            ret_str = alphabet.substring(halfLen) + ret_str + alphabet.substring(0, halfLen);
            final int excess = ret_str.length() - this.minHashLength;
            if (excess > 0) {
                final int start_pos = excess / 2;
                ret_str = ret_str.substring(start_pos, start_pos + this.minHashLength);
            }
        }

        return ret_str;
    }
1143946
private int outputHexCharref() {
        final byte[] utfBytes;
        final int utfP;
        int utfLen;

        if (caseInsensitiveEquals(lastError.source, "UTF-32BE".getBytes())) {
            utfBytes = lastError.errorBytes;
            utfP = lastError.errorBytesP;
            utfLen = lastError.errorBytesLength;
        } else {
            Ptr utfLenA = new Ptr();

            // TODO: better calculation?
            byte[] utfBuf = new byte[lastError.errorBytesLength * UTF32BEEncoding.INSTANCE.maxLength()];
            utfBytes = allocateConvertedString(lastError.source, "UTF-32BE".getBytes(), lastError.errorBytes, lastError.errorBytesP, lastError.errorBytesLength, utfBuf, utfLenA);

            if (utfBytes == null) return -1;
            utfP = 0;
            utfLen = utfLenA.p;
        }

        if (utfLen % 4 != 0) return -1;

        int p = utfP;
        while (4 <= utfLen) {
            int u = 0; // long ??
            u += (utfBytes[p] & 0xff) << 24;
            u += (utfBytes[p + 1] & 0xff) << 16;
            u += (utfBytes[p + 2] & 0xff) << 8;
            u += (utfBytes[p + 3] & 0xff);
            byte[] charrefbuf = String.format("&#x%X;", u).getBytes(); // FIXME: use faster sprintf ??

            if (insertOutput(charrefbuf, 0, charrefbuf.length, "US-ASCII".getBytes()) == -1) return -1;

            p += 4;
            utfLen -= 4;
        }

        return 0;
    }
673262
public String getHexStringLower() {
		int len = getVInt();
		byte[] hex = new byte[len];
		System.arraycopy(buf, bufPosition, hex, 0, hex.length);
		bufPosition += hex.length;
		return toHex(hex, false);
	}
253055
public String getHexStringUpper() {
		int len = getVInt();
		byte[] hex = new byte[len];
		System.arraycopy(buf, bufPosition, hex, 0, hex.length);
		bufPosition += hex.length;
		return toHex(hex, true);
	}
227154
protected static String byteToHexString(byte ib) {
		char[] Digit = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
		char[] ob = new char[2];
		ob[0] = Digit[(ib >>> 4) & 0X0f];
		ob[1] = Digit[ib & 0X0F];
		String s = new String(ob);
		return s;
	}
877211
public static String toHexString(byte b) {
		final char[] out = new char[2];
		out[0] = hexDigits[(0xF0 & b) >>> 4];
		out[1] = hexDigits[0x0F & b];
		return new String(out);
	}
147649
public static function charAsciiAlphaUpperArray()
    {
        static $result = array();

        if (!$result) {
            for ($i = 65; $i < 91; ++$i) {
                $result[] = \chr($i);
            }
        }

        return $result;
    }
412244
private static String hex4(char c) {
		char[] r = new char[] { '0', '0', '0', '0' };
		int i = 3;
		while (c > 0) {
			r[i] = HEX_DIGITS[c & 0xF];
			c >>>= 4;
			--i;
		}
		return new String(r);
	}
1197478
String getHexString() {
        final ByteBuffer bytes = getBytes();
        final byte[] array = new byte[bytes.remaining()];
        bytes.get(array);
        final StringBuilder sb = new StringBuilder();
        for (byte b : array) {
            sb.append(String.format("%02x ", b));
        }
        return sb.toString();
    }