public static void Main(string[] argv) { if (argv.Length == 2) { try { NBFSNet NBFS = new NBFSNet(); if (argv[0].ToLower().Equals("encode")) { Console.WriteLine(Convert.ToBase64String(NBFS.EncodeBinaryXML(System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(argv[1]))))); } else { Console.WriteLine(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(NBFS.DecodeBinaryXML(Convert.FromBase64String(argv[1]))))); } } catch (Exception e) { Console.WriteLine(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(e.Message))); } } else { Console.WriteLine("Usage: NBFS [encode|decode] Base64Data\n\nNOTE: All output, including exceptions, will be returned as a Base64 string."); } }
public static void Main(string[] argv) { if (argv.Length == 2) { try { NBFSNet NBFS = new NBFSNet(); if (argv[0].ToLower().Equals("encode")) { Console.WriteLine(Convert.ToBase64String(NBFS.EncodeBinaryXML(System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(argv[1]))))); } else { Console.WriteLine(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(NBFS.DecodeBinaryXML(Convert.FromBase64String(argv[1]))))); } } catch (Exception e) { Console.WriteLine(Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(e.Message))); } } else { Console.WriteLine("Usage: NBFS [encode|decode] Base64Data\n\nNOTE: All output, including exceptions, will be returned as a Base64 string."); } }
public static void Main(string[] argv) { if (argv.Length == 2) { string outputPathSuffix = "_out"; string inputPath = argv[1]; try { NBFSNet NBFS = new NBFSNet(); // Some antiviruses might block large console output, so, using file output instead if (argv[0].ToLower().Equals("encode")) { //Console.WriteLine(Convert.ToBase64String(NBFS.EncodeBinaryXML(System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String((new StreamReader(inputPath)).ReadToEnd()))))); File.WriteAllBytes(inputPath + outputPathSuffix, NBFS.EncodeBinaryXML(System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String((new StreamReader(inputPath)).ReadToEnd())))); } else { //Console.WriteLine(NBFS.DecodeBinaryXML(Convert.FromBase64String((new StreamReader(argv[1])).ReadToEnd()))); File.WriteAllText(inputPath + outputPathSuffix, NBFS.DecodeBinaryXML(Convert.FromBase64String((new StreamReader(inputPath)).ReadToEnd()))); } } catch (Exception e) { Console.WriteLine(e.Message + " " + e.StackTrace); } } else { Console.WriteLine("Usage: NBFS [encode|decode] Base64DataFile."); } }