Created
May 11, 2015 19:14
-
-
Save sebug/ddd82f3a14d152404c46 to your computer and use it in GitHub Desktop.
Base 64 streamed in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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