From abc470942082eccb89edc13541f8b57fef6a172a Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Tue, 29 Dec 2020 07:35:26 +0000 Subject: [PATCH] added stdout store support --- rinseoffcli/RinseOffCLI.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rinseoffcli/RinseOffCLI.cs b/rinseoffcli/RinseOffCLI.cs index a33603d..91e62fc 100644 --- a/rinseoffcli/RinseOffCLI.cs +++ b/rinseoffcli/RinseOffCLI.cs @@ -24,7 +24,7 @@ namespace rinseoffcli { class Program { - public static string version = "0.0.0"; + public static string version = "1.0.0"; enum ErrorCode : byte { // Exit error codes indexed from 1 @@ -44,6 +44,7 @@ namespace rinseoffcli static void showHelp(ErrorCode exitCode = ErrorCode.InvaildArgs){ Console.WriteLine("RinseOff " + version + " High level secure-erasure utility"); + Console.WriteLine("For stdout output, specify 'stdout' as the data file for the store command"); Console.WriteLine("Must specify keygen or store/load, then a file name followed by a key file.\nFormat: "); Environment.Exit((int) exitCode); } @@ -107,6 +108,14 @@ namespace rinseoffcli static void storeData(string filepath, string keypath){ byte[] encryptedInput = new byte[0]; + void writeStdoutBytes(byte[] data){ + var stdout = Console.OpenStandardOutput(); + foreach (byte b in data){ + stdout.WriteByte(b); + } + stdout.Flush(); + } + byte[] readUntilClose(){ // Read binary from STDIN until close var readData = new List(); @@ -138,6 +147,10 @@ namespace rinseoffcli stderrWrite("Failed to read key file " + keypath); Environment.Exit((int)ErrorCode.FailedToReadKeyFile); } + if (filepath == "stdout"){ + writeStdoutBytes(encryptedInput); + return; + } try{ File.WriteAllBytes(filepath, encryptedInput); }