Skip to content

Commit d4e74ca

Browse files
authored
Merge pull request #2 from gowon/release/v1.0.0
Release v1.0.0
2 parents 7e99a83 + 412b7bf commit d4e74ca

39 files changed

+1237
-123
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"jetbrains.resharper.globaltools": {
6+
"version": "2021.1.2",
7+
"commands": [
8+
"jb"
9+
]
10+
}
11+
}
12+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Continuous Build
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Add mask
12+
run: |
13+
echo "::add-mask::${{ secrets.FEEDZ_API_KEY }}"
14+
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0 # https://github.com/devlooped/GitInfo/issues/140#issuecomment-757224054
18+
19+
- name: Setup .NET Core 3.1
20+
uses: actions/setup-dotnet@v1
21+
with:
22+
dotnet-version: '3.1.x'
23+
24+
- name: Setup .NET 5
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: '5.0.x'
28+
29+
- name: Setup NuGet
30+
uses: nuget/setup-nuget@v1
31+
with:
32+
nuget-version: 'latest'
33+
34+
- name: Build solution
35+
run: dotnet build --configuration Release
36+
37+
- name: Test solution
38+
run: dotnet test --configuration Release --no-build --logger "trx;LogFileName=test-results.trx" --collect "XPlat Code Coverage" --results-directory "./test-results"
39+
40+
- name: Generate test report
41+
uses: dorny/test-reporter@v1
42+
if: success() || failure() # run this step even if previous step failed
43+
with:
44+
name: Test Results
45+
path: test-results/*.trx # Path to test results
46+
reporter: dotnet-trx # Format of test results
47+
48+
- name: Upload coverage to Codecov
49+
uses: codecov/codecov-action@v1
50+
with:
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
file: ./test-results/*.xml
53+
54+
- name: Nuget Push
55+
run: nuget push ${{ env.GITHUB_WORKSPACE }}/**/*.nupkg -Source https://f.feedz.io/gowon/pre-release/nuget/index.json -ApiKey ${{ secrets.FEEDZ_API_KEY }} -SkipDuplicate
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Nightly Build from Develop Branch
2+
3+
on: [workflow_dispatch]
4+
# on:
5+
# schedule:
6+
# - cron: '0 23 * * *'
7+
8+
jobs:
9+
check_date:
10+
runs-on: ubuntu-latest
11+
name: Check latest commit
12+
outputs:
13+
should_run: ${{ steps.should_run.outputs.should_run }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
# https://github.com/devlooped/GitInfo/issues/140#issuecomment-757224054
18+
fetch-depth: 0
19+
ref: develop
20+
- name: print latest_commit
21+
run: echo ${{ github.sha }}
22+
- id: should_run
23+
continue-on-error: true
24+
name: check latest commit is less than a day
25+
if: ${{ github.event_name == 'schedule' }}
26+
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
27+
build:
28+
# https://stackoverflow.com/a/67527144/7644876
29+
needs: check_date
30+
if: ${{ needs.check_date.outputs.should_run != 'false' }}
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Add mask
34+
run: |
35+
echo "::add-mask::${{ secrets.FEEDZ_API_KEY }}"
36+
- name: Setup .NET Core 3.1
37+
uses: actions/setup-dotnet@v1
38+
with:
39+
dotnet-version: '3.1.x'
40+
- name: Setup .NET 5
41+
uses: actions/setup-dotnet@v1
42+
with:
43+
dotnet-version: '5.0.x'
44+
- name: Setup NuGet
45+
uses: nuget/setup-nuget@v1
46+
with:
47+
nuget-version: 'latest'
48+
- name: Build solution
49+
run: dotnet build --configuration Release
50+
- name: Nuget Push
51+
run: nuget push ${{ env.GITHUB_WORKSPACE }}/**/*.nupkg -Source https://f.feedz.io/gowon/pre-release/nuget/index.json -ApiKey ${{ secrets.FEEDZ_API_KEY }} -SkipDuplicate

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ bld/
4040
Generated\ Files/
4141

4242
# MSTest test Results
43+
test-results/
4344
[Tt]est[Rr]esult*/
4445
[Bb]uild[Ll]og.*
4546

README.md

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,90 @@
1-
# kryptera
1+
# Kryptera
22

3-
Kryptera is a quick-and-dirty .NET Core Tool to encrypt and decrypt files using AEAD AES-256-GCM, as well as an encryption key generator. Kryptera means "encrypt" in Swedish.
3+
[![Nuget](https://img.shields.io/nuget/dt/Kryptera?color=blue&label=Kryptera%20downloads)](https://www.nuget.org/packages/Kryptera)
4+
[![Nuget](https://img.shields.io/nuget/dt/Kryptera.Tools?color=blue&label=Kryptera.Tools%20downloads)](https://www.nuget.org/packages/Kryptera.Tools)
5+
[![codecov](https://codecov.io/gh/gowon/kryptera/branch/main/graph/badge.svg?token=RJUNMU04ZE)](https://codecov.io/gh/gowon/kryptera)
6+
7+
Kryptera is a .NET Core Tool to quickly encrypt and decrypt files using AEAD AES-256-GCM algorithm from [CryptHash.NET](https://github.com/alecgn/crypthash-net/), as well as an encryption key generator. Kryptera means "encrypt" in [Swedish](https://translate.google.com/?sl=sv&tl=en&text=kryptera&op=translate).
8+
9+
## Install
10+
11+
|Package|Stable|Preview|
12+
|-|-|-|
13+
|Kryptera|[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Kryptera)](https://www.nuget.org/packages/Kryptera)|[![feedz.io](https://img.shields.io/badge/endpoint.svg?url=https%3A%2F%2Ff.feedz.io%2Fgowon%2Fpre-release%2Fshield%2FKryptera%2Flatest)](https://f.feedz.io/gowon/pre-release/packages/Kryptera/latest/download)|
14+
|Kryptera.Tools|[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/Kryptera.Tools)](https://www.nuget.org/packages/Kryptera.Tools)|[![feedz.io](https://img.shields.io/badge/endpoint.svg?url=https%3A%2F%2Ff.feedz.io%2Fgowon%2Fpre-release%2Fshield%2FKryptera.Tools%2Flatest)](https://f.feedz.io/gowon/pre-release/packages/Kryptera.Tools/latest/download)|
15+
16+
The Kryptera library can be obtained by either locally cloning this git repository and building it or via NuGet/Feedz:
17+
18+
```shell
19+
Install-Package Kryptera
20+
```
21+
22+
or
23+
24+
```shell
25+
dotnet add package Kryptera
26+
```
27+
28+
The command-line tool for encrypting and decrypting files can be installed through the `dotnet` CLI:
29+
30+
```shell
31+
dotnet install --global Kryptera.Tools
32+
```
33+
34+
after which it is available for use in your shell as `kryptera`.
435

536
## Usage
637

38+
You can use the `--help` option to get detailed information about the commands.
39+
40+
```shell
41+
kryptera
42+
43+
Usage:
44+
kryptera [options] [command]
45+
46+
Options:
47+
-v, --verbosity <Critical|Debug|Error|Information|None|Trace|Warning> Set output verbosity
48+
--version Show version information
49+
-?, -h, --help Show help and usage information
50+
51+
Commands:
52+
encrypt <source> Encrypt a file or directory using AES-256-GCM
53+
decrypt <source> Decrypt a file or directory using AES-256-GCM
54+
generate Generate a new AES-256 key
55+
```
56+
57+
### Create an encryption key
58+
59+
You can create a new encryption key using the following command:
60+
61+
```shell
62+
> kryptera generate
63+
tRKvyxIcQA6jV0eUoH/LA1QFlDSNUQRfzDJqU9CSvzM=
64+
```
65+
66+
The output is sent directly to the console, and can be piped directly as input into other applications or scripts.
67+
68+
### Encrypt a file or directory
69+
70+
You can encrypt a file or directory using the following command:
71+
72+
```shell
73+
kryptera encrypt --key <KEY> <SOURCE>
74+
```
75+
76+
The filenames for the encrypted files will have `.aes` appended to them to make them easy to distinguish from the original files.
77+
78+
### Decrypt a file of directory
79+
80+
You can decrypt a file or directory using the following command:
81+
82+
```shell
83+
kryptera decrypt --key <KEY> <SOURCE>
84+
```
85+
86+
If the encrypted files have `.aes` extensions, then the filenames for the decrypted files with have this extension removed. If the encrypted file extensions are not `.aes`, then the filenames of the decrypted files with have `-decrypted` appended to the name right before the extension.
87+
788
## License
889

9-
MIT
90+
MIT

kryptera.sln

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.31005.135
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kryptera.Tools", "src\Kryptera.Tools\Kryptera.Tools.csproj", "{7A3A3CE9-0F53-4CA7-BBD9-FFE63ECB3A64}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kryptera.Tools", "src\Kryptera.Tools\Kryptera.Tools.csproj", "{7A3A3CE9-0F53-4CA7-BBD9-FFE63ECB3A64}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{730BE3AF-871D-4F7B-A5DB-B46D01A5BBA9}"
99
ProjectSection(SolutionItems) = preProject
1010
README.md = README.md
1111
EndProjectSection
1212
EndProject
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kryptera.Tools.Tests", "tests\Kryptera.Tools.Tests\Kryptera.Tools.Tests.csproj", "{7B216500-A738-43CB-8A0F-94BBF04E104C}"
14+
EndProject
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kryptera", "src\Kryptera\Kryptera.csproj", "{D854EC6F-2BF8-4D38-80F9-FF729A5715A7}"
16+
EndProject
1317
Global
1418
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1519
Debug|Any CPU = Debug|Any CPU
@@ -20,6 +24,14 @@ Global
2024
{7A3A3CE9-0F53-4CA7-BBD9-FFE63ECB3A64}.Debug|Any CPU.Build.0 = Debug|Any CPU
2125
{7A3A3CE9-0F53-4CA7-BBD9-FFE63ECB3A64}.Release|Any CPU.ActiveCfg = Release|Any CPU
2226
{7A3A3CE9-0F53-4CA7-BBD9-FFE63ECB3A64}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{7B216500-A738-43CB-8A0F-94BBF04E104C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{7B216500-A738-43CB-8A0F-94BBF04E104C}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{7B216500-A738-43CB-8A0F-94BBF04E104C}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{7B216500-A738-43CB-8A0F-94BBF04E104C}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{D854EC6F-2BF8-4D38-80F9-FF729A5715A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{D854EC6F-2BF8-4D38-80F9-FF729A5715A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{D854EC6F-2BF8-4D38-80F9-FF729A5715A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{D854EC6F-2BF8-4D38-80F9-FF729A5715A7}.Release|Any CPU.Build.0 = Release|Any CPU
2335
EndGlobalSection
2436
GlobalSection(SolutionProperties) = preSolution
2537
HideSolutionNode = FALSE

src/Directory.Build.targets

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project>
2+
<Target Name="SetVersion" BeforeTargets="Build;GetPackageVersion;_IntrospectProjectProperties;GitInfoReport" DependsOnTargets="GitVersion">
3+
<PropertyGroup>
4+
<!-- Packages for feature branches are marked as "alpha" (ex., 2.1.0-alpha426e8bcf) -->
5+
<GitSemVerDashLabel Condition="$(GitBranch.Contains('feature'))">alpha.$(GitCommit)</GitSemVerDashLabel>
6+
7+
<!-- Packages for release branches are marked as "rc", release candidates (ex., 2.1.0-rc426e8bcf) -->
8+
<GitSemVerDashLabel Condition="$(GitBranch.Contains('develop'))">beta.$(GitCommit)</GitSemVerDashLabel>
9+
10+
<!-- Packages for release branches are marked as "rc", release candidates (ex., 2.1.0-rc426e8bcf) -->
11+
<GitSemVerDashLabel Condition="$(GitBranch.Contains('release'))">rc.$(GitCommit)</GitSemVerDashLabel>
12+
13+
<!-- Packages for the master branch have no suffix (ex., 2.1.0) -->
14+
<GitSemVerDashLabel Condition="$(GitBranch.Contains('master'))"></GitSemVerDashLabel>
15+
16+
<DefineConstants Condition="$(GitBranch.Contains('feature'))">ALPHA_BUILD;$(DefineConstants)</DefineConstants>
17+
18+
<PackageVersion Condition="'$(GitSemVerDashLabel)' != ''">$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)-$(GitSemVerDashLabel)</PackageVersion>
19+
<PackageVersion Condition="'$(GitSemVerDashLabel)' == ''">$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</PackageVersion>
20+
</PropertyGroup>
21+
</Target>
22+
</Project>

src/GlobalAssemblyInfo.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyProduct("Kryptera")]
4+
[assembly: AssemblyCompany("Gowon, Ltd.")]
5+
[assembly: AssemblyCopyright("Copyright © Gowon, Ltd. 2021")]
6+
7+
#if DEBUG
8+
[assembly: AssemblyConfiguration("Debug")]
9+
#else
10+
[assembly: AssemblyConfiguration("Release")]
11+
#endif
12+
13+
#pragma warning disable CS0436 // Type conflicts with imported type
14+
[assembly: AssemblyVersion(ThisAssembly.Version)]
15+
[assembly: AssemblyFileVersion(ThisAssembly.SimpleVersion)]
16+
[assembly: AssemblyInformationalVersion(ThisAssembly.InformationalVersion)]
17+
#pragma warning restore CS0436 // Type conflicts with imported type
18+
19+
// ReSharper disable once CheckNamespace
20+
internal partial class ThisAssembly
21+
{
22+
/// <summary>
23+
/// Simple release-like version number, like 4.0.1 for a cycle 5, SR1 build.
24+
/// </summary>
25+
public const string SimpleVersion =
26+
Git.SemVer.Major + "." + Git.SemVer.Minor + "." + Git.SemVer.Patch;
27+
28+
/// <summary>
29+
/// Full version, including commits since base version file, like 4.0.1.598
30+
/// </summary>
31+
public const string Version = SimpleVersion;
32+
33+
/// <summary>
34+
/// Full version, plus branch and commit short sha, like 4.0.1.598-cycle6+39cf84e
35+
/// </summary>
36+
#if ALPHA_BUILD
37+
public const string InformationalVersion = Version + "-alpha" + "+" + Git.Commit;
38+
39+
#else
40+
public const string InformationalVersion = Version + "+" + Git.Commit;
41+
42+
#endif
43+
}

src/Kryptera.Tools/CommandLine/CommandHandlerFactory.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
using System.CommandLine.Invocation;
44
using System.CommandLine.Parsing;
5+
using System.Threading;
56
using Commands;
67
using MediatR;
78
using Microsoft.Extensions.DependencyInjection;
@@ -11,23 +12,14 @@ public static class CommandHandlerFactory
1112
{
1213
public static ICommandHandler CreateFor<TRequest>() where TRequest : ICommandLineRequest, new()
1314
{
14-
return CommandHandler.Create(async (IHost host, ParseResult parseResult) =>
15-
{
16-
var mediator = host.Services.GetRequiredService<IMediator>();
17-
18-
var request = new TRequest();
19-
request.Map(parseResult);
20-
21-
// ReSharper disable once SuspiciousTypeConversion.Global
22-
if (request is IRequest<int> returnRequest)
15+
return CommandHandler.Create(
16+
async (IHost host, ParseResult parseResult, CancellationToken cancellationToken) =>
2317
{
24-
return await mediator.Send(returnRequest);
25-
}
26-
27-
request.Map(parseResult);
28-
await mediator.Send(request);
29-
return 0;
30-
});
18+
var mediator = host.Services.GetRequiredService<IMediator>();
19+
var request = new TRequest();
20+
request.Map(parseResult);
21+
await mediator.Send(request, cancellationToken);
22+
});
3123
}
3224
}
3325
}

0 commit comments

Comments
 (0)