Skip to content

Commit

Permalink
Cryptographic object identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayshinva committed Nov 21, 2020
1 parent 3838657 commit ecebeed
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Kryptos/Kryptos/Kryptos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
<Version>0.0.6</Version>
<Authors>Vijayshinva Karnure</Authors>
<Description>A .NET core tool for cryptography.</Description>
Expand Down
3 changes: 2 additions & 1 deletion Kryptos/Kryptos/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ static async Task<int> Main(string[] args)
.WireUpHmacSha256Commands()
.WireUpHmacSha384Commands()
.WireUpHmacSha512Commands()
.WireUpSriCommands();
.WireUpSriCommands().
WireUpOidCommands();

return await rootCommand.InvokeAsync(args);
}
Expand Down
40 changes: 40 additions & 0 deletions Kryptos/Kryptos/WireUpOidExtensions.cs
Original file line number Diff line number Diff line change
@@ -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<string>(new string[] { "--text", "-t" }, "Input Text"));

oidCommand.Handler = CommandHandler.Create<string, IConsole>((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;
}
}
}
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/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
Expand Down

0 comments on commit ecebeed

Please sign in to comment.