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

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

?? base64.java

?? 一個很實用的東東
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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;

/**
 * Provides Base64 encoding and decoding as defined by RFC 2045.
 * 
 * <p>This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> 
 * from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One: 
 * Format of Internet Message Bodies</cite> by Freed and Borenstein.</p> 
 *
 * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>
 * @author Apache Software Foundation
 * @since 1.0-dev
 * @version $Id: Base64.java,v 1.20 2004/05/24 00:21:24 ggregory Exp $
 */
public class Base64 implements BinaryEncoder, BinaryDecoder {

    /**
     * Chunk size per RFC 2045 section 6.8.
     * 
     * <p>The {@value} character limit does not count the trailing CRLF, but counts 
     * all other characters, including any equal signs.</p>
     * 
     * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 6.8</a>
     */
    static final int CHUNK_SIZE = 76;

    /**
     * Chunk separator per RFC 2045 section 2.1.
     * 
     * @see <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045 section 2.1</a>
     */
    static final byte[] CHUNK_SEPARATOR = "\r\n".getBytes();

    /**
     * The base length.
     */
    static final int BASELENGTH = 255;

    /**
     * Lookup length.
     */
    static final int LOOKUPLENGTH = 64;

    /**
     * Used to calculate the number of bits in a byte.
     */
    static final int EIGHTBIT = 8;

    /**
     * Used when encoding something which has fewer than 24 bits.
     */
    static final int SIXTEENBIT = 16;

    /**
     * Used to determine how many bits data contains.
     */
    static final int TWENTYFOURBITGROUP = 24;

    /**
     * Used to get the number of Quadruples.
     */
    static final int FOURBYTE = 4;

    /**
     * Used to test the sign of a byte.
     */
    static final int SIGN = -128;
    
    /**
     * Byte used to pad output.
     */
    static final byte PAD = (byte) '=';

    // Create arrays to hold the base64 characters and a 
    // lookup for base64 chars
    private static byte[] base64Alphabet = new byte[BASELENGTH];
    private static byte[] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];

    // Populating the lookup and character arrays
    static {
        for (int i = 0; i < BASELENGTH; i++) {
            base64Alphabet[i] = (byte) -1;
        }
        for (int i = 'Z'; i >= 'A'; i--) {
            base64Alphabet[i] = (byte) (i - 'A');
        }
        for (int i = 'z'; i >= 'a'; i--) {
            base64Alphabet[i] = (byte) (i - 'a' + 26);
        }
        for (int i = '9'; i >= '0'; i--) {
            base64Alphabet[i] = (byte) (i - '0' + 52);
        }

        base64Alphabet['+'] = 62;
        base64Alphabet['/'] = 63;

        for (int i = 0; i <= 25; i++) {
            lookUpBase64Alphabet[i] = (byte) ('A' + i);
        }

        for (int i = 26, j = 0; i <= 51; i++, j++) {
            lookUpBase64Alphabet[i] = (byte) ('a' + j);
        }

        for (int i = 52, j = 0; i <= 61; i++, j++) {
            lookUpBase64Alphabet[i] = (byte) ('0' + j);
        }

        lookUpBase64Alphabet[62] = (byte) '+';
        lookUpBase64Alphabet[63] = (byte) '/';
    }

    private static boolean isBase64(byte octect) {
        if (octect == PAD) {
            return true;
        } else if (base64Alphabet[octect] == -1) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * Tests a given byte array to see if it contains
     * only valid characters within the Base64 alphabet.
     *
     * @param arrayOctect byte array to test
     * @return true if all bytes are valid characters in the Base64
     *         alphabet or if the byte array is empty; false, otherwise
     */
    public static boolean isArrayByteBase64(byte[] arrayOctect) {

        arrayOctect = discardWhitespace(arrayOctect);

        int length = arrayOctect.length;
        if (length == 0) {
            // shouldn't a 0 length array be valid base64 data?
            // return false;
            return true;
        }
        for (int i = 0; i < length; i++) {
            if (!isBase64(arrayOctect[i])) {
                return false;
            }
        }
        return true;
    }

    /**
     * Encodes binary data using the base64 algorithm but
     * does not chunk the output.
     *
     * @param binaryData binary data to encode
     * @return Base64 characters
     */
    public static byte[] encodeBase64(byte[] binaryData) {
        return encodeBase64(binaryData, false);
    }

    /**
     * Encodes binary data using the base64 algorithm and chunks
     * the encoded output into 76 character blocks
     *
     * @param binaryData binary data to encode
     * @return Base64 characters chunked in 76 character blocks
     */
    public static byte[] encodeBase64Chunked(byte[] binaryData) {
        return encodeBase64(binaryData, true);
    }


    /**
     * Decodes an Object using the base64 algorithm.  This method
     * is provided in order to satisfy the requirements of the
     * Decoder interface, and will throw a DecoderException if the
     * supplied object is not of type byte[].
     *
     * @param pObject Object to decode
     * @return An object (of type byte[]) containing the 
     *         binary data which corresponds to the byte[] supplied.
     * @throws DecoderException if the parameter supplied is not
     *                          of type byte[]
     */
    public Object decode(Object pObject) throws DecoderException {
        if (!(pObject instanceof byte[])) {
            throw new DecoderException("Parameter supplied to Base64 decode is not a byte[]");
        }
        return decode((byte[]) pObject);
    }

    /**
     * Decodes a byte[] containing containing
     * characters in the Base64 alphabet.
     *
     * @param pArray A byte array containing Base64 character data
     * @return a byte array containing binary data
     */
    public byte[] decode(byte[] pArray) {
        return decodeBase64(pArray);
    }

    /**
     * Encodes binary data using the base64 algorithm, optionally
     * chunking the output into 76 character blocks.
     *
     * @param binaryData Array containing binary data to encode.
     * @param isChunked if isChunked is true this encoder will chunk
     *                  the base64 output into 76 character blocks
     * @return Base64-encoded data.
     */
    public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
        int lengthDataBits = binaryData.length * EIGHTBIT;
        int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
        int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
        byte encodedData[] = null;
        int encodedDataLength = 0;
        int nbrChunks = 0;

        if (fewerThan24bits != 0) {
            //data not divisible by 24 bit
            encodedDataLength = (numberTriplets + 1) * 4;
        } else {
            // 16 or 8 bit
            encodedDataLength = numberTriplets * 4;
        }

        // If the output is to be "chunked" into 76 character sections, 
        // for compliance with RFC 2045 MIME, then it is important to 
        // allow for extra length to account for the separator(s)
        if (isChunked) {

            nbrChunks =
                (CHUNK_SEPARATOR.length == 0 ? 0 : (int) Math.ceil((float) encodedDataLength / CHUNK_SIZE));
            encodedDataLength += nbrChunks * CHUNK_SEPARATOR.length;
        }

        encodedData = new byte[encodedDataLength];

        byte k = 0, l = 0, b1 = 0, b2 = 0, b3 = 0;

        int encodedIndex = 0;
        int dataIndex = 0;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99九九99九九九视频精品| 亚洲一二三区在线观看| 精品中文字幕一区二区| 日韩视频免费观看高清完整版在线观看| 亚洲夂夂婷婷色拍ww47| 欧美日韩大陆一区二区| 捆绑变态av一区二区三区| 日韩欧美一二三区| 国产在线精品视频| 欧美高清在线一区| 色94色欧美sute亚洲13| 亚洲成a人片综合在线| 欧美一区日韩一区| 国产一区91精品张津瑜| 国产精品人成在线观看免费| 色欧美片视频在线观看在线视频| 一区二区成人在线| 日韩视频永久免费| 成人毛片视频在线观看| 亚洲一区自拍偷拍| 欧美成人在线直播| 92精品国产成人观看免费| 午夜精品久久久久久久 | 国产精品99久久久久久久女警| 亚洲国产高清在线| 欧美日韩一区精品| 国产精品亚洲专一区二区三区| 成人免费在线视频观看| 91精品国产综合久久久蜜臀粉嫩| 国产精品91一区二区| 亚洲精品成人天堂一二三| 精品国产伦理网| 一本大道久久a久久精品综合| 日韩成人免费在线| 18欧美乱大交hd1984| 欧美大肚乱孕交hd孕妇| 91成人免费电影| 成人在线综合网| 日韩av一区二区在线影视| 国产精品每日更新在线播放网址| 91精品国产免费久久综合| 99久久精品国产一区二区三区| 日韩国产在线一| 尤物在线观看一区| 久久久久9999亚洲精品| 欧美日韩免费在线视频| 99免费精品视频| 国产一区二区三区在线观看免费 | 99久久久精品免费观看国产蜜| 天天色综合成人网| 亚洲欧洲日韩女同| 久久久99免费| 日韩一区二区精品在线观看| 色网站国产精品| 不卡一区中文字幕| 国产在线播放一区三区四| 欧美a一区二区| 午夜国产不卡在线观看视频| 亚洲免费在线看| 综合欧美亚洲日本| 国产日韩欧美高清| 久久综合九色综合97婷婷女人 | 国产精品视频观看| 久久嫩草精品久久久久| 日韩欧美二区三区| 91精品国产综合久久小美女| 欧美视频一区二区三区| 色狠狠av一区二区三区| 91性感美女视频| 99热这里都是精品| 97国产精品videossex| 成人理论电影网| 不卡一区二区中文字幕| 盗摄精品av一区二区三区| 国产麻豆精品95视频| 国产在线精品免费| 国产精品99久久久久久宅男| 国产精品99久久久久| 国v精品久久久网| av影院午夜一区| 91国模大尺度私拍在线视频| 色婷婷久久一区二区三区麻豆| 欧洲一区二区三区免费视频| 欧美综合久久久| 欧美日韩一级二级三级| 欧美一区二区视频免费观看| 欧美tk—视频vk| 日本一区二区三区久久久久久久久不 | 99久久国产综合精品女不卡| 成人av动漫网站| 色94色欧美sute亚洲13| 欧美日韩高清一区| 日韩一级二级三级精品视频| 日韩亚洲欧美在线| 久久久五月婷婷| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品丝袜黑色高跟| 亚洲另类在线制服丝袜| 天天综合日日夜夜精品| 蜜芽一区二区三区| 国产精品一区二区三区99| voyeur盗摄精品| 欧美日韩国产另类不卡| 日韩欧美国产精品| 国产精品久久久久久久午夜片| 亚洲人吸女人奶水| 青娱乐精品视频| 99久久综合国产精品| 欧美日韩国产精选| 2020国产成人综合网| 亚洲丝袜自拍清纯另类| 五月天丁香久久| 国产精品69久久久久水密桃| 94-欧美-setu| 欧美精品一区二区久久久| 自拍偷自拍亚洲精品播放| 日本成人在线电影网| 国产宾馆实践打屁股91| 欧美色综合久久| 国产欧美一区二区精品性色超碰 | 成人丝袜18视频在线观看| 91传媒视频在线播放| 久久综合久久99| 亚洲亚洲精品在线观看| 国产乱子轮精品视频| 欧美性一级生活| 久久久国产精品不卡| 亚洲va天堂va国产va久| 国产精品1区2区| 91麻豆精品国产91久久久更新时间 | 国产精品久久午夜| 九九九精品视频| 在线观看日韩电影| 中文字幕久久午夜不卡| 全部av―极品视觉盛宴亚洲| 色婷婷精品大在线视频| 国产日韩在线不卡| 喷白浆一区二区| 欧美日韩一级二级| 亚洲免费电影在线| 成人性生交大片免费看视频在线| 91精品国产91热久久久做人人| 国产精品二三区| 国产精品一区三区| 日韩精品影音先锋| 日韩影院免费视频| 欧美色综合影院| 亚洲一区视频在线观看视频| 国产91清纯白嫩初高中在线观看 | 久久久久9999亚洲精品| 免费一级片91| 91精品国产全国免费观看| 亚洲国产美女搞黄色| 波多野结衣中文字幕一区| 国产三区在线成人av| 狠狠色狠狠色合久久伊人| 欧美一区二区精美| 五月天国产精品| 欧美日本韩国一区| 五月激情综合婷婷| 欧美日韩免费不卡视频一区二区三区| 国产精品乱码一区二区三区软件 | 国产福利91精品一区| 国产亚洲成av人在线观看导航| 久久国产免费看| 国产校园另类小说区| 欧洲精品中文字幕| 日韩精品视频网站| 久久久久久久一区| 欧美在线看片a免费观看| 国产一区二区导航在线播放| 免费久久99精品国产| 国产98色在线|日韩| 国产女人aaa级久久久级| 国产成人精品亚洲日本在线桃色| 精品91自产拍在线观看一区| 裸体一区二区三区| 精品国产乱码久久久久久图片 | 亚洲国产精品成人综合色在线婷婷| 国内精品嫩模私拍在线| 久久久午夜电影| 成人精品免费网站| 一区二区三区在线视频免费观看| 91福利在线观看| 青青草国产精品亚洲专区无| 精品久久人人做人人爰| 久久99精品久久久久久| 国产色一区二区| 91在线视频18| 亚洲午夜视频在线观看| 51精品秘密在线观看| 国产一区二区三区免费| 亚洲丝袜精品丝袜在线| 欧美亚一区二区| 狠狠色丁香久久婷婷综合丁香| 欧美国产精品v| 色av综合在线| 精品一区二区三区在线视频| 国产精品嫩草99a| 欧美日韩成人高清|