diff --git a/Kryptos/Kryptos/Kryptos.csproj b/Kryptos/Kryptos/Kryptos.csproj index 4140434..c5e0fb4 100644 --- a/Kryptos/Kryptos/Kryptos.csproj +++ b/Kryptos/Kryptos/Kryptos.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + netcoreapp3.1;net5.0 0.0.6 Vijayshinva Karnure A .NET core tool for cryptography. diff --git a/Kryptos/Kryptos/Program.cs b/Kryptos/Kryptos/Program.cs index fec92ce..eec838a 100644 --- a/Kryptos/Kryptos/Program.cs +++ b/Kryptos/Kryptos/Program.cs @@ -27,7 +27,8 @@ static async Task Main(string[] args) .WireUpHmacSha256Commands() .WireUpHmacSha384Commands() .WireUpHmacSha512Commands() - .WireUpSriCommands(); + .WireUpSriCommands(). + WireUpOidCommands(); return await rootCommand.InvokeAsync(args); } diff --git a/Kryptos/Kryptos/WireUpOidExtensions.cs b/Kryptos/Kryptos/WireUpOidExtensions.cs new file mode 100644 index 0000000..740d778 --- /dev/null +++ b/Kryptos/Kryptos/WireUpOidExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Invocation; +using System.CommandLine.IO; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace Kryptos +{ + public static class WireUpOidExtensions + { + public static RootCommand WireUpOidCommands(this RootCommand rootCommand) + { + Command oidCommand = new Command("oid", "Cryptographic object identifier"); + oidCommand.AddOption(new Option(new string[] { "--text", "-t" }, "Input Text")); + + oidCommand.Handler = CommandHandler.Create((text, console) => + { + try + { + var oid = new Oid(text); + + console.Out.WriteLine($"{oid.FriendlyName} : {oid.Value}"); + } + catch (Exception ex) + { + console.Out.WriteLine(ex.Message); + return 22; + } + return 0; + }); + + rootCommand.AddCommand(oidCommand); + + return rootCommand; + } + } +} diff --git a/README.md b/README.md index 5fc1167..a022778 100644 --- a/README.md +++ b/README.md @@ -49,27 +49,28 @@ kryptos --help ``` ## Examples -1. Generate Base64 encoded string - ``` - kryptos base64 enc -t "The quick brown fox jumps over the lazy dog." - ``` -2. Decode Base64 encoded string + +1. Decode Base64 encoded string ``` kryptos base64 dec -t "VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4=" ``` -3. Generate SHA-256 hash of file +2. Generate SHA-256 hash of file ``` kryptos sha256 hash -i .\ubuntu-20.04-desktop-amd64.iso ``` -4. Decode a JWT token +3. Decode a JWT token ``` kryptos jwt dec -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IlZpamF5c2hpbnZhIEthcm51cmUiLCJpYXQiOjE1MTYyMzkwMjIsImF1ZCI6Imh0dHBzOi8vZ2l0aHViLmNvbS92aWpheXNoaW52YS9rcnlwdG9zIn0.ufklYra5bLYKM-FWnmxI0Tsw_ILmTIDK0cJ7ZkPfwfE ``` -5. Generate Subresource Integrity +4. Generate Subresource Integrity ``` kryptos sri hash -u https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css ``` - +5. Look up Cryptographic Object Identifier + ``` + kryptos oid -t 1.3.6.1.5.5.7.3.1 + ``` + ## Contributing - Fork the repo on [GitHub][git-repo] - Clone the project to your own machine