Esempio n. 1
0
        public void Base64_Encode_ByteArray_Byte()
        {
            var encoder = new BaseNDecoder(BaseNAlphabet.Base64Alphabet);
            var output  = new byte[4 * 1024];

            for (var i = 0; i < this.data.Length;)
            {
                var flush = this.data.Length - i <= BaseNAlphabet.Base64Alphabet.EncodingBlockSize;
                encoder.Convert(this.data, i, this.data.Length - i, output, 0, output.Length, flush, out var inputUsed, out var outputUsed, out var complete);
                i += inputUsed;
            }
        }
Esempio n. 2
0
        public void Base64_Encode_Span_Byte()
        {
            var encoder    = new BaseNDecoder(BaseNAlphabet.Base64Alphabet);
            var inputSpan  = this.data.AsSpan();
            var output     = new byte[4 * 1024];
            var outputSpan = output.AsSpan();

            for (var i = 0; i < this.data.Length;)
            {
                var flush = this.data.Length - i <= BaseNAlphabet.Base64Alphabet.EncodingBlockSize;
                encoder.Convert(inputSpan.Slice(i), outputSpan, flush, out var inputUsed, out var outputUsed, out var complete);
                i += inputUsed;
            }
        }
Esempio n. 3
0
        public unsafe void Base64_Encode_Ptr_Byte()
        {
            var encoder = new BaseNDecoder(BaseNAlphabet.Base64Alphabet);
            var output  = new byte[4 * 1024];

            fixed(byte *inputPtr = this.data)
            fixed(byte *outputPtr = output)
            for (var i = 0; i < this.data.Length; )
            {
                var flush = this.data.Length - i <= BaseNAlphabet.Base64Alphabet.EncodingBlockSize;

                encoder.Convert(inputPtr + i, this.data.Length - i, outputPtr, output.Length, flush, out var inputUsed, out var outputUsed, out var complete);
                i += inputUsed;
            }
        }