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

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

?? base64.java

?? 解觖java技術中后臺無法上傳數給的情況
?? JAVA
字號:
/*
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/misc/Base64.java,v 1.9 2006/04/15 02:59:19 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.9 $
 * $Date: 2006/04/15 02:59:19 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2006 by MyVietnam.net
 *
 * All copyright notices regarding MyVietnam and MyVietnam CoreLib
 * MUST remain intact in the scripts and source code.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at MyVietnam net
 *
 */
/*
 * $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/misc/Base64.java,v 1.9 2006/04/15 02:59:19 minhnn Exp $
 * $Revision: 1.9 $
 * $Date: 2006/04/15 02:59:19 $
 *
 * ====================================================================
 *
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 1999 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution, if
 *    any, must include the following acknowlegement:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowlegement may appear in the software itself,
 *    if and wherever such third-party acknowlegements normally appear.
 *
 * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
 *    Foundation" must not be used to endorse or promote products derived
 *    from this software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache"
 *    nor may "Apache" appear in their names without prior written
 *    permission of the Apache Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * [Additional notices, if required by prior licensing conditions]
 *
 */

package net.myvietnam.mvncore.misc;

/**
 * This class provides encode/decode for RFC 2045 Base64 as defined by
 * RFC 2045, N. Freed and N. Borenstein.  <a
 * href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>:
 * Multipurpose Internet Mail Extensions (MIME) Part One: Format of
 * Internet Message Bodies. Reference 1996
 *
 * @author Jeffrey Rodriguez
 * @version $Id: Base64.java,v 1.9 2006/04/15 02:59:19 minhnn Exp $
 */
public final class  Base64
{
    static private final int  BASELENGTH         = 255;
    static private final int  LOOKUPLENGTH       = 64;
    static private final int  TWENTYFOURBITGROUP = 24;
    static private final int  EIGHTBIT           = 8;
    static private final int  SIXTEENBIT         = 16;
    static private final int  SIXBIT             = 6;
    static private final int  FOURBYTE           = 4;
    static private final int  SIGN               = -128;
    static private final byte PAD                = (byte) '=';
    static private byte [] base64Alphabet       = new byte[BASELENGTH];
    static private byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
    //static private final Log log = LogSource.getInstance("org.apache.commons.util.Base64");

    static
    {
        for (int i = 0; i < BASELENGTH; i++ )
        {
            base64Alphabet[i] = -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) '/';
    }

    public static boolean isBase64( String isValidString )
    {
        return isArrayByteBase64(isValidString.getBytes());
    }

    public static boolean isBase64( byte octect )
    {
        //shall we ignore white space? JEFF??
        return (octect == PAD || base64Alphabet[octect] != -1);
    }

    public static boolean isArrayByteBase64( byte[] 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 ( !Base64.isBase64(arrayOctect[i]) )
                return false;
        }
        return true;
    }

    /**
     * Encodes hex octects into Base64.
     *
     * @param binaryData Array containing binary data to encode.
     * @return Base64-encoded data.
     */
    public static byte[] encode( byte[] binaryData )
    {
        int      lengthDataBits    = binaryData.length*EIGHTBIT;
        int      fewerThan24bits   = lengthDataBits%TWENTYFOURBITGROUP;
        int      numberTriplets    = lengthDataBits/TWENTYFOURBITGROUP;
        byte     encodedData[]     = null;


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

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

        int encodedIndex = 0;
        int dataIndex   = 0;
        int i           = 0;
        //log.debug("number of triplets = " + numberTriplets);
        for ( i = 0; i<numberTriplets; i++ )
        {
            dataIndex = i*3;
            b1 = binaryData[dataIndex];
            b2 = binaryData[dataIndex + 1];
            b3 = binaryData[dataIndex + 2];

            //log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);

            l  = (byte)(b2 & 0x0f);
            k  = (byte)(b1 & 0x03);

            encodedIndex = i * 4;
            byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
            byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
            byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);

            encodedData[encodedIndex]   = lookUpBase64Alphabet[ val1 ];
            //log.debug( "val2 = " + val2 );
            //log.debug( "k4   = " + (k<<4) );
            //log.debug(  "vak  = " + (val2 | (k<<4)) );
            encodedData[encodedIndex+1] =
                lookUpBase64Alphabet[ val2 | ( k<<4 )];
            encodedData[encodedIndex+2] =
                lookUpBase64Alphabet[ (l <<2 ) | val3 ];
            encodedData[encodedIndex+3] = lookUpBase64Alphabet[ b3 & 0x3f ];
        }

        // form integral number of 6-bit groups
        dataIndex    = i*3;
        encodedIndex = i*4;
        if (fewerThan24bits == EIGHTBIT )
        {
            b1 = binaryData[dataIndex];
            k = (byte) ( b1 &0x03 );
            //log.debug("b1=" + b1);
            //log.debug("b1<<2 = " + (b1>>2) );
            byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
            encodedData[encodedIndex]     = lookUpBase64Alphabet[ val1 ];
            encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ k<<4 ];
            encodedData[encodedIndex + 2] = PAD;
            encodedData[encodedIndex + 3] = PAD;
        }
        else if (fewerThan24bits == SIXTEENBIT)
        {

            b1 = binaryData[dataIndex];
            b2 = binaryData[dataIndex +1 ];
            l = (byte) (b2 & 0x0f);
            k = (byte) (b1 & 0x03);

            byte val1 = ((b1 & SIGN) == 0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
            byte val2 = ((b2 & SIGN) == 0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);

            encodedData[encodedIndex]     = lookUpBase64Alphabet[ val1 ];
            encodedData[encodedIndex + 1] =
                lookUpBase64Alphabet[ val2 | ( k<<4 )];
            encodedData[encodedIndex + 2] = lookUpBase64Alphabet[ l<<2 ];
            encodedData[encodedIndex + 3] = PAD;
        }

        return encodedData;
    }

    /**
     * Decodes Base64 data into octects
     *
     * @param base64Data Byte array containing Base64 data
     * @return Array containing decoded data.
     */
    public static byte[] decode( byte[] base64Data )
    {
        // handle the edge case, so we don't have to worry about it later
        if(base64Data.length == 0) { return new byte[0]; }

        int      numberQuadruple    = base64Data.length/FOURBYTE;
        byte     decodedData[]      = null;
        byte     b1=0,b2=0,b3=0, b4=0, marker0=0, marker1=0;

        // Throw away anything not in base64Data

        int encodedIndex = 0;
        int dataIndex    = 0;
        {
            // this sizes the output array properly - rlw
            int lastData = base64Data.length;
            // ignore the '=' padding
            while (base64Data[lastData-1] == PAD)
            {
                if (--lastData == 0)
                {
                    return new byte[0];
                }
            }
            decodedData = new byte[ lastData - numberQuadruple ];
        }

        for (int i = 0; i < numberQuadruple; i++)
        {
            dataIndex = i * 4;
            marker0   = base64Data[dataIndex + 2];
            marker1   = base64Data[dataIndex + 3];

            b1 = base64Alphabet[base64Data[dataIndex]];
            b2 = base64Alphabet[base64Data[dataIndex +1]];

            if (marker0 != PAD && marker1 != PAD)
            {
                //No PAD e.g 3cQl
                b3 = base64Alphabet[ marker0 ];
                b4 = base64Alphabet[ marker1 ];

                decodedData[encodedIndex]   = (byte)(  b1 <<2 | b2>>4 ) ;
                decodedData[encodedIndex + 1] =
                    (byte)(((b2 & 0xf)<<4 ) |( (b3>>2) & 0xf) );
                decodedData[encodedIndex + 2] = (byte)( b3<<6 | b4 );
            }
            else if (marker0 == PAD)
            {
                //Two PAD e.g. 3c[Pad][Pad]
                decodedData[encodedIndex]   = (byte)(  b1 <<2 | b2>>4 ) ;
            }
            else if (marker1 == PAD)
            {
                //One PAD e.g. 3cQ[Pad]
                b3 = base64Alphabet[ marker0 ];

                decodedData[encodedIndex]   = (byte)(  b1 <<2 | b2>>4 );
                decodedData[encodedIndex + 1] =
                    (byte)(((b2 & 0xf)<<4 ) |( (b3>>2) & 0xf) );
            }
            encodedIndex += 3;
        }
        return decodedData;
    }


}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线视频精品一区| 精品无人区卡一卡二卡三乱码免费卡| 韩日av一区二区| 国产一区激情在线| 精品一区二区三区av| 久久国产人妖系列| 黄页网站大全一区二区| 日韩成人免费电影| 久久99精品久久久久久久久久久久| 五月综合激情网| 午夜精品福利在线| 韩日欧美一区二区三区| 成人理论电影网| 91在线观看下载| 欧美精品一二三| 精品理论电影在线观看| 欧美韩国日本不卡| 一区二区三区不卡视频在线观看| 夜夜嗨av一区二区三区网页| 亚洲高清免费视频| 亚洲a一区二区| 国产自产2019最新不卡| 91色porny蝌蚪| 久久免费国产精品| 喷水一区二区三区| 欧美性受xxxx| 欧美国产成人在线| 韩国一区二区在线观看| 色综合久久六月婷婷中文字幕| 欧美乱熟臀69xxxxxx| 中文字幕欧美一区| 另类专区欧美蜜桃臀第一页| 精品国免费一区二区三区| 一区二区在线电影| 91精品国产综合久久小美女| 亚洲国产精品久久一线不卡| 91久久久免费一区二区| 亚洲国产人成综合网站| 在线播放视频一区| 老司机精品视频一区二区三区| 91精品国产综合久久香蕉的特点| 欧美色电影在线| 图片区小说区区亚洲影院| 日韩一区和二区| 精品一区二区av| 在线观看日产精品| 夜夜揉揉日日人人青青一国产精品| 91福利精品第一导航| 亚洲欧美日本在线| 欧美高清精品3d| 精品在线播放免费| 亚洲欧洲综合另类在线| 欧美在线观看禁18| 午夜久久久久久久久| 欧美写真视频网站| 欧美va亚洲va国产综合| 国产精品羞羞答答xxdd| 国产丝袜在线精品| 91伊人久久大香线蕉| 亚洲国产精品久久艾草纯爱| 91精品在线观看入口| 精品夜夜嗨av一区二区三区| 亚洲国产精品黑人久久久| 91原创在线视频| 美女在线视频一区| 中文字幕乱码一区二区免费| 色噜噜夜夜夜综合网| 蜜臀av一级做a爰片久久| 国产亚洲自拍一区| 欧美在线观看视频一区二区三区| 蜜桃av噜噜一区二区三区小说| 国产精品伦理在线| 欧美一级国产精品| 99精品视频中文字幕| 婷婷久久综合九色国产成人 | 久久99精品国产麻豆婷婷| 国产精品久久二区二区| 欧美肥大bbwbbw高潮| 粉嫩av一区二区三区在线播放| 亚洲线精品一区二区三区八戒| 国产亚洲人成网站| 欧美精品久久一区| 91官网在线观看| aaa亚洲精品| 日本道色综合久久| 在线观看日韩精品| 欧美一区二区精美| 精品福利二区三区| 亚洲国产成人午夜在线一区| 日韩女优av电影在线观看| 亚洲第一会所有码转帖| 亚洲乱码国产乱码精品精小说 | 欧美在线一区二区| www.av亚洲| 91亚洲精华国产精华精华液| 色噜噜狠狠成人中文综合| 欧美日韩激情一区二区三区| 午夜欧美大尺度福利影院在线看 | 99这里只有精品| 国产在线一区二区| 国产91精品久久久久久久网曝门| 国产精品高潮呻吟久久| 最新高清无码专区| 亚洲综合视频在线观看| 亚洲国产日日夜夜| 蜜臀av一区二区| 成人精品免费网站| 欧美色男人天堂| 精品成人一区二区三区| 精品久久人人做人人爱| 中文字幕第一区| 国产日韩欧美不卡在线| 亚洲一二三四在线| 蜜桃一区二区三区四区| 国产大片一区二区| 奇米影视在线99精品| 国产福利91精品一区二区三区| 成人激情开心网| 欧美一区二区三区的| 国产欧美一区二区精品久导航| 亚洲精品成a人| 国产一区 二区| 精品播放一区二区| 欧美成人vr18sexvr| 欧美人与禽zozo性伦| 一区二区高清免费观看影视大全| 一区二区三区成人| 精品制服美女丁香| 国产福利精品导航| 懂色av一区二区三区免费观看| 91女厕偷拍女厕偷拍高清| 欧美日韩高清影院| 久久精品视频在线免费观看| 欧美高清dvd| 国产色产综合色产在线视频| 久久久久久久久一| 亚洲一区二区三区四区五区黄 | 夜夜嗨av一区二区三区四季av| 日韩在线一区二区| 91免费观看国产| 精品国产123| 亚洲精品中文在线观看| 欧美激情艳妇裸体舞| 日韩1区2区日韩1区2区| 粉嫩欧美一区二区三区高清影视 | 成人在线一区二区三区| 91精品国产综合久久婷婷香蕉 | 日韩一区二区免费电影| 亚洲欧洲美洲综合色网| 日韩高清国产一区在线| 色吧成人激情小说| 国产精品理论在线观看| 爽好多水快深点欧美视频| 97久久超碰国产精品| 久久久美女艺术照精彩视频福利播放 | 国产成人精品一区二| 国产精品一级二级三级| 欧美日韩一二三区| 一区二区三区精品在线观看| 成人av网站免费| 久久久99免费| 日韩不卡一二三区| 在线视频综合导航| 亚洲成人免费在线| 91美女福利视频| 国产蜜臀97一区二区三区| 国产又黄又大久久| av亚洲精华国产精华| 国产精品美日韩| 91视频在线观看免费| 夜色激情一区二区| 色播五月激情综合网| 亚洲另类春色国产| 欧美日韩小视频| 日韩制服丝袜av| 国产三级三级三级精品8ⅰ区| 国产很黄免费观看久久| 一区在线观看视频| 91麻豆自制传媒国产之光| 亚洲免费伊人电影| 日韩欧美国产电影| 国产成人综合网站| 亚洲综合在线第一页| 欧美精品一区二区三区一线天视频 | 亚洲国产精品高清| 欧美日韩精品欧美日韩精品一综合| 精品国产1区二区| 91精品91久久久中77777| 久久99热这里只有精品| 亚洲一区二区在线免费看| 久久精品视频在线看| 欧美xxxx在线观看| 欧美性猛交一区二区三区精品| 国产黄色精品网站| 中文久久乱码一区二区| 精品电影一区二区| 日韩一区二区三| 日韩欧美国产一区二区三区| 久久99在线观看| 日韩成人免费看|