Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehjohn committed Jan 13, 2024
1 parent 7c57a92 commit 8597815
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Security.Console/Infrastructure/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
using System.Linq;
using System.Text;
using Security.Crypto;
using Security.CustomEncoding;

namespace Security.Console.Infrastructure
{
public static class EntryPoint
{
public static int Main(string[] args)
{
return Parser.Default.ParseArguments<GenerateKeyOptions, SplitSecretOptions, CombineOptions, ToBase64Options, FromBase64Options, EncryptOptions, DecryptOptions>(args)
return Parser.Default.ParseArguments<GenerateKeyOptions, SplitSecretOptions, CombineOptions, ToBase64Options, FromBase64Options, EncryptOptions, DecryptOptions, ToBase16Options>(args)
.MapResult(
(GenerateKeyOptions options) => GenerateKey(options),
(SplitSecretOptions options) => SplitSecret(options),
Expand All @@ -22,9 +23,21 @@ public static int Main(string[] args)
(FromBase64Options options) => FromBase64(options),
(EncryptOptions options) => Encrypt(options),
(DecryptOptions options) => Decrypt(options),
(ToBase16Options options) => ToBase16(options),
_ => 1);
}


private static int ToBase16(ToBase16Options options)
{
var encoder = new Base16Encoder();

Output($"\n Original text: {options.Text}");
Output($"\n Base 16: {encoder.GetString(Encoding.UTF8.GetBytes(options.Text))}\n");

return 0;
}

private static int Encrypt(EncryptOptions options)
{
var key = Convert.FromBase64String(options.Key);
Expand Down
11 changes: 11 additions & 0 deletions src/Security.Console/Infrastructure/Settings/ToBase16Options.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using CommandLine;

namespace Security.Console.Infrastructure.Settings
{
[Verb("ToBase16", HelpText = "Convert a string to base 16.")]
public class ToBase16Options
{
[Option('t', "Text", Required = true, HelpText = "The text to convert to base 64, in double quotes if it contains spaces.")]
public string Text { get; set; }
}
}

0 comments on commit 8597815

Please sign in to comment.