亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hex.java

?? 一個很實用的東東
?? JAVA
字號:
/*
 * Copyright 2001-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */ 

package org.apache.commons.codec.binary;

import org.apache.commons.codec.BinaryDecoder;
import org.apache.commons.codec.BinaryEncoder;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;

/**
 * Hex encoder and decoder.
 * 
 * @since 1.1
 * @author Apache Software Foundation
 * @version $Id: Hex.java,v 1.13 2004/04/18 18:22:33 ggregory Exp $
 */
public class Hex implements BinaryEncoder, BinaryDecoder {

    /** 
     * Used building output as Hex 
     */
    private static final char[] DIGITS = {
        '0', '1', '2', '3', '4', '5', '6', '7',
           '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
    };

    /**
     * Converts an array of characters representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     * 
     * @param data An array of characters containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied char array.
     * @throws DecoderException Thrown if an odd number or illegal of characters 
     *         is supplied
     */
    public static byte[] decodeHex(char[] data) throws DecoderException {

        int len = data.length;

        if ((len & 0x01) != 0) {
            throw new DecoderException("Odd number of characters.");
        }

        byte[] out = new byte[len >> 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; j < len; i++) {
            int f = toDigit(data[j], j) << 4;
            j++;
            f = f | toDigit(data[j], j);
            j++;
            out[i] = (byte) (f & 0xFF);
        }

        return out;
    }

    /**
     * Converts a hexadecimal character to an integer.
     *  
     * @param ch A character to convert to an integer digit
     * @param index The index of the character in the source
     * @return An integer
     * @throws DecoderException Thrown if ch is an illegal hex character
     */
    protected static int toDigit(char ch, int index) throws DecoderException {
        int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new DecoderException("Illegal hexadecimal charcter " + ch + " at index " + index);
        }
        return digit;
    }

    /**
     * Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order.
     * The returned array will be double the length of the passed array, as it takes two characters to represent any
     * given byte.
     * 
     * @param data
     *                  a byte[] to convert to Hex characters
     * @return A char[] containing hexidecimal characters
     */
    public static char[] encodeHex(byte[] data) {

        int l = data.length;

           char[] out = new char[l << 1];

           // two characters form the hex value.
           for (int i = 0, j = 0; i < l; i++) {
               out[j++] = DIGITS[(0xF0 & data[i]) >>> 4 ];
               out[j++] = DIGITS[ 0x0F & data[i] ];
           }

           return out;
    }
	
    /**
     * Converts an array of character bytes representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     * 
     * @param array An array of character bytes containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied byte array (representing characters).
     * @throws DecoderException Thrown if an odd number of characters is supplied
     *                   to this function
     * @see #decodeHex(char[])
     */
	public byte[] decode(byte[] array) throws DecoderException {
		return decodeHex(new String(array).toCharArray());
	}
	
    /**
     * Converts a String or an array of character bytes representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed String or array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     * 
     * @param object A String or, an array of character bytes containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied byte array (representing characters).
     * @throws DecoderException Thrown if an odd number of characters is supplied
     *                   to this function or the object is not a String or char[]
     * @see #decodeHex(char[])
     */
	public Object decode(Object object) throws DecoderException {
		try {
            char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object;
		    return decodeHex(charArray);
		} catch (ClassCastException e) {
		    throw new DecoderException(e.getMessage());
		}
	}
	
    /**
     * Converts an array of bytes into an array of bytes for the characters representing the
     * hexidecimal values of each byte in order. The returned array will be
     * double the length of the passed array, as it takes two characters to
     * represent any given byte.
     *
     * @param array a byte[] to convert to Hex characters
     * @return A byte[] containing the bytes of the hexidecimal characters
     * @see #encodeHex(byte[])
     */
	public byte[] encode(byte[] array) {
		return new String(encodeHex(array)).getBytes();
	}

    /**
     * Converts a String or an array of bytes into an array of characters representing the
     * hexidecimal values of each byte in order. The returned array will be
     * double the length of the passed String or array, as it takes two characters to
     * represent any given byte.
     *
     * @param object a String, or byte[] to convert to Hex characters
     * @return A char[] containing hexidecimal characters
     * @throws EncoderException Thrown if the given object is not a String or byte[]
     * @see #encodeHex(byte[])
     */
	public Object encode(Object object) throws EncoderException {	
		try {
            byte[] byteArray = object instanceof String ? ((String) object).getBytes() : (byte[]) object;
			return encodeHex(byteArray);
		} catch (ClassCastException e) {
			throw new EncoderException(e.getMessage());
		}
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产亚洲一区二区三区在线观看 | 亚洲欧美国产三级| 67194成人在线观看| 日本国产一区二区| 91视频xxxx| 96av麻豆蜜桃一区二区| eeuss国产一区二区三区| 成人午夜激情片| 国产ts人妖一区二区| 国产不卡视频在线播放| 成人高清av在线| www.亚洲精品| 久久er99热精品一区二区| 日本午夜精品一区二区三区电影 | 欧美一区二区三区在线视频| 欧美三级资源在线| 制服丝袜中文字幕一区| 51午夜精品国产| 日韩视频在线观看一区二区| 精品久久久久久最新网址| 国产亚洲精品aa| 国产精品嫩草99a| 一区二区三区在线观看动漫| 亚洲一区二区视频| 蜜臀av一区二区在线免费观看| 久久不见久久见免费视频1| 国产成人免费在线观看| 91免费版在线| 日韩一区二区三区高清免费看看| 精品国产污污免费网站入口| 综合激情网...| 日本美女一区二区三区视频| 国产精品乡下勾搭老头1| 99久久免费视频.com| 欧美精品欧美精品系列| 久久久久久99久久久精品网站| 国产精品女人毛片| 日本不卡不码高清免费观看| 成人动漫视频在线| 欧美男男青年gay1069videost| xf在线a精品一区二区视频网站| 中文字幕在线不卡| 蜜臀av一区二区| 色久综合一二码| 国产欧美在线观看一区| 亚洲国产精品久久一线不卡| 国产一区二区三区国产| 欧美影院午夜播放| 欧美国产1区2区| 蜜臀久久久99精品久久久久久| 国产乱码精品一区二区三区五月婷 | 亚洲成人黄色影院| 国产99一区视频免费| 91精品中文字幕一区二区三区| 国产精品午夜在线观看| 美女国产一区二区| 欧美丝袜丝nylons| 亚洲视频在线观看三级| 国内精品国产成人国产三级粉色| 欧美午夜宅男影院| 亚洲欧洲国产专区| 国产成人av网站| 精品国产伦一区二区三区免费 | 精品制服美女丁香| 欧美天堂一区二区三区| 最新高清无码专区| 成人激情免费视频| 国产三级精品在线| 国产一区二区不卡在线 | av亚洲精华国产精华精华| 日韩免费高清av| 日韩不卡手机在线v区| 91久久香蕉国产日韩欧美9色| 久久久91精品国产一区二区精品 | 欧美精品一区二区三区蜜臀 | 韩国成人在线视频| 欧美一级淫片007| 日本美女一区二区三区| 欧美sm极限捆绑bd| 精品一区中文字幕| 久久久久久久综合日本| 国产精品一线二线三线精华| 久久免费视频色| 国产999精品久久| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品资源在线看| 欧美激情资源网| 成人免费视频视频在线观看免费| 国产日本欧美一区二区| 成人免费毛片高清视频| 亚洲欧洲在线观看av| 色综合久久综合| 亚洲bdsm女犯bdsm网站| 欧美一卡二卡在线| 久久疯狂做爰流白浆xx| 久久久久国色av免费看影院| 国产成人av影院| 亚洲女人****多毛耸耸8| 在线免费亚洲电影| 香蕉加勒比综合久久| 欧美成人免费网站| 不卡在线视频中文字幕| 一区二区三区四区在线播放| 666欧美在线视频| 国产另类ts人妖一区二区| 国产精品国模大尺度视频| 91麻豆精东视频| 日本欧美在线看| 久久久美女毛片| 在线观看国产一区二区| 久久精品国产亚洲aⅴ| 国产精品素人视频| 欧美日高清视频| 国产精品 日产精品 欧美精品| 亚洲三级在线看| 日韩精品中文字幕一区二区三区 | 色噜噜狠狠成人网p站| 国产精品一区免费视频| 亚洲综合免费观看高清在线观看| 欧美一区二区在线免费观看| 成人免费视频视频| 免费成人你懂的| 亚洲一区电影777| 国产欧美一区在线| 欧美一级午夜免费电影| 91年精品国产| 国产成人精品影院| 蜜桃免费网站一区二区三区| 亚洲欧美偷拍卡通变态| 欧美精品一区二区三区四区| 欧美日高清视频| 99国产精品国产精品毛片| 精品在线一区二区三区| 午夜国产精品影院在线观看| 日韩理论片一区二区| 久久精品视频网| 日韩一区二区三区免费观看| 欧美在线观看一区| 91丨porny丨最新| 丁香亚洲综合激情啪啪综合| 久久99国产精品麻豆| 爽好久久久欧美精品| 亚洲欧美另类小说视频| 中文字幕成人网| 国产欧美日韩三级| 久久一区二区三区四区| 日韩一级黄色片| 欧美一级搡bbbb搡bbbb| 制服丝袜成人动漫| 欧美精品丝袜久久久中文字幕| 在线视频综合导航| 99精品视频在线播放观看| 夫妻av一区二区| av亚洲精华国产精华| 97se狠狠狠综合亚洲狠狠| 91网站最新网址| 91美女片黄在线观看| 欧美综合亚洲图片综合区| 91免费视频网址| 欧美日韩一区二区不卡| 欧美日韩大陆在线| 欧美高清dvd| 日韩免费观看高清完整版在线观看| 欧美日韩成人激情| 欧美一级搡bbbb搡bbbb| 欧美xxxxxxxx| 国产免费久久精品| 亚洲日本在线视频观看| 亚洲激情图片小说视频| 日韩中文字幕av电影| 男女男精品网站| 国产精品538一区二区在线| 盗摄精品av一区二区三区| 91在线视频播放| 欧美性生活影院| 精品乱人伦一区二区三区| 国产欧美日韩激情| 亚洲色图视频网| 午夜在线电影亚洲一区| 精品在线观看免费| caoporn国产精品| 69堂国产成人免费视频| 亚洲精品一区二区三区香蕉| 国产精品久久久久久久久图文区| 亚洲三级视频在线观看| 人人爽香蕉精品| 成人免费三级在线| 91精品国产一区二区人妖| 久久精品夜夜夜夜久久| 亚洲精品高清在线观看| 国产一区视频导航| 91国产成人在线| 久久久精品国产免大香伊| 一区二区激情视频| 国产精品2024| 日韩精品一区二区三区四区 | 欧美日本乱大交xxxxx| 久久久久97国产精华液好用吗| 亚洲色图在线看| 国产一区二区精品在线观看|