示例#1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="stream">Stream which to encode/decode.</param>
        /// <param name="owner">Specifies if Base64Stream is owner of <b>stream</b>.</param>
        /// <param name="addLineBreaks">Specifies if encoder inserts CRLF after each 76 bytes.</param>
        /// <param name="access">This stream access mode.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>stream</b> is null reference.</exception>
        public Base64Stream(Stream stream,bool owner,bool addLineBreaks,FileAccess access)
        {
            if(stream == null){
                throw new ArgumentNullException("stream");
            }

            m_pStream       = stream;
            m_IsOwner       = owner;
            m_AddLineBreaks = addLineBreaks;
            m_AccessMode    = access;

            m_pDecodedBlock = new byte[8000];
            m_pBase64       = new Base64();
        }
示例#2
0
        /// <summary>
        /// Decodes specified base64 data.
        /// </summary>
        /// <param name="data">Base64 data.</param>
        /// <returns>Returns decoded data.</returns>
        /// <exception cref="ArgumentNullException">Is raised when <b>data</b> is null reference.</exception>
        public static byte[] FromBase64(byte[] data)
        {
            if(data == null){
                throw new ArgumentNullException("data");
            }

            Base64 base64 = new Base64();

            return base64.Decode(data,0,data.Length,true);
        }