Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Base 64 streamed in C#
using System;
using System.IO;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace Base64
{
public class Base64Stream
{
public static int Main(string[] args)
{
try
{
return Wain(args, Console.OpenStandardInput(),
Console.OpenStandardOutput());
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
return 1;
}
}
private static int Wain(IReadOnlyCollection<string> args,
Stream input, Stream output)
{
if (input == null)
{
throw new ArgumentNullException("input");
}
if (output == null)
{
throw new ArgumentNullException("output");
}
using (CryptoStream cs = new CryptoStream(output, new ToBase64Transform(), CryptoStreamMode.Write))
{
input.CopyTo(cs);
}
return 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.