Example #1
0
        private static byte[] DecodeThroughTextWriter(BinaryCodec codec, string inputData)
        {
            using (var memoryStream = new MemoryStream())
            {
                var random      = new Random(5);
                int inputOffset = 0;
                int inputLength = inputData.Length;

                using (var codecWriter = new BinaryDecoderWriter(codec, memoryStream))
                {
                    while (true)
                    {
                        int charsToProcess = (inputLength > 0) ? random.Next(1, inputLength) : 0;
                        if (charsToProcess == 0)
                        {
                            break;
                        }

                        codecWriter.Write(inputData.Substring(inputOffset, charsToProcess));
                        inputOffset += charsToProcess;
                        inputLength -= charsToProcess;
                    }

                    codecWriter.Flush();
                }

                return(memoryStream.ToArray());
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            var random     = new Random(10);
            var inputBytes = new byte[4096];

            random.NextBytes(inputBytes);

            var encodedText = BinaryCodecs.Ascii85.GetString(inputBytes);

            var memStream    = new MemoryStream();
            var decodeWriter = new BinaryDecoderWriter(BinaryCodecs.Base64Standard, memStream);

            for (int iIndex = 0; iIndex < encodedText.Length; iIndex++)
            {
                decodeWriter.WriteLine();
            }

            decodeWriter.Flush();

            Console.WriteLine("Done");
            Console.ReadLine();
        }