Skip to content

Commit cc72b8b

Browse files
First release.
1 parent c73f709 commit cc72b8b

13 files changed

Lines changed: 471 additions & 2 deletions

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Package Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on v1.0, v2.1.5, etc.
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # Needed to create the release and upload assets
13+
14+
steps:
15+
- name: Checkout Code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup .NET
19+
uses: actions/setup-dotnet@v4
20+
with:
21+
dotnet-version: '8.0.x'
22+
23+
- name: Get Version from Tag
24+
id: get_version
25+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
26+
27+
- name: Publish App
28+
# We publish to a local 'publish' folder
29+
run: dotnet publish OutSystems.YAEmailValidator/OutSystems.YAEmailValidator.csproj -c Release -r linux-x64 --self-contained false -o ./publish
30+
31+
- name: Create Versioned Zip
32+
# This creates YAEmailValidator_v1.0.0.zip (or whatever your tag is)
33+
run: |
34+
cd ./publish
35+
zip -r ../YAEmailValidator_${{ steps.get_version.outputs.VERSION }}.zip .
36+
cd ..
37+
38+
- name: Create GitHub Release
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
files: YAEmailValidator_${{ steps.get_version.outputs.VERSION }}.zip
42+
name: Release ${{ steps.get_version.outputs.VERSION }}
43+
draft: false
44+
prerelease: false
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
## =========================================================================
2+
## .NET / Visual Studio
3+
## =========================================================================
4+
5+
# Build artifacts
6+
[Bb]in/
7+
[Oo]bj/
8+
out/
9+
artifacts/
10+
publish/
11+
12+
# User-specific files
13+
*.user
14+
*.userosscache
15+
*.sln.docstates
16+
*.suo
17+
18+
# Visual Studio cache & temporary files
19+
.vs/
20+
*.opendb
21+
*.dbmdl
22+
*.VC.db
23+
*.VC.opendb
24+
25+
# MSBuild / Roslyn logs
26+
*.log
27+
*.binlog
28+
*.msvcclog
29+
30+
## =========================================================================
31+
## NuGet
32+
## =========================================================================
33+
34+
# Restore artifacts
35+
project.lock.json
36+
project.assets.json
37+
*.nuget.props
38+
*.nuget.targets
39+
40+
# Package cache
41+
packages/
42+
43+
## =========================================================================
44+
## Release Assets (Zips & Packages)
45+
## =========================================================================
46+
47+
# Specific requested patterns
48+
YAEmailValidator_Asset.zip
49+
YAEmailValidator_v*.zip
50+
51+
# General safety for all compressed files
52+
*.zip
53+
*.tar.gz
54+
*.7z
55+
*.nupkg
56+
57+
## =========================================================================
58+
## IDE / Editor Specific
59+
## =========================================================================
60+
61+
# VS Code
62+
.vscode/
63+
!.vscode/settings.json
64+
!.vscode/tasks.json
65+
!.vscode/launch.json
66+
!.vscode/extensions.json
67+
*.code-workspace
68+
69+
# JetBrains Rider
70+
.idea/
71+
*.sln.iml
72+
73+
# Windows / macOS system files
74+
.DS_Store
75+
Thumbs.db
76+
77+
## =========================================================================
78+
## Environment & Testing
79+
## =========================================================================
80+
81+
# Secrets and Local Config
82+
.env
83+
*.dev.local
84+
appsettings.Development.json
85+
86+
# Test Results & Coverage
87+
TestResults/
88+
*.sequenced
89+
*.coverage
90+
*.opencoverxml
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
10+
<LangVersion>10</LangVersion>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
15+
<PackageReference Include="NUnit" Version="4.4.0" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0" />
17+
<PackageReference Include="NUnit.Analyzers" Version="4.11.2">
18+
<PrivateAssets>all</PrivateAssets>
19+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
20+
</PackageReference>
21+
<PackageReference Include="coverlet.collector" Version="6.0.4">
22+
<PrivateAssets>all</PrivateAssets>
23+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
24+
</PackageReference>
25+
</ItemGroup>
26+
27+
</Project>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using NUnit.Framework;
2+
using System;
3+
using System.Text;
4+
using System.Security.Cryptography;
5+
6+
namespace OutSystems.NetChecksumUtils.Tests
7+
{
8+
[TestFixture]
9+
public class ComputeChecksumTests
10+
{/*
11+
private readonly NetChecksumUtils _sut = new();
12+
13+
private static string ComputeExpected(string algorithm, string text)
14+
{
15+
byte[] data = Encoding.UTF8.GetBytes(text);
16+
return algorithm.Trim().ToUpperInvariant() switch
17+
{
18+
"SHA256" or "SHA-256" => Convert.ToHexString(SHA256.HashData(data)),
19+
"SHA512" or "SHA-512" => Convert.ToHexString(SHA512.HashData(data)),
20+
"MD5" => Convert.ToHexString(MD5.Create().ComputeHash(data)),
21+
_ => throw new ArgumentException("Unsupported algorithm", nameof(algorithm))
22+
};
23+
}
24+
25+
[TestCase("SHA256")]
26+
[TestCase("SHA-256")]
27+
[TestCase("sha256")]
28+
public void ComputeChecksum_SHA256_Variants_ReturnsExpected(string algorithm)
29+
{
30+
string text = "hello";
31+
string expected = ComputeExpected(algorithm, text);
32+
33+
_sut.ComputeChecksum(algorithm, text, out var actual, out var ticks);
34+
35+
Assert.That(actual, Is.EqualTo(expected));
36+
Assert.That(ticks, Is.GreaterThan(0));
37+
}
38+
39+
[TestCase("SHA512")]
40+
[TestCase("SHA-512")]
41+
[TestCase("sha512")]
42+
public void ComputeChecksum_SHA512_Variants_ReturnsExpected(string algorithm)
43+
{
44+
string text = "the quick brown fox";
45+
string expected = ComputeExpected(algorithm, text);
46+
47+
_sut.ComputeChecksum(algorithm, text, out var actual, out var ticks);
48+
49+
Assert.That(actual, Is.EqualTo(expected));
50+
Assert.That(ticks, Is.GreaterThan(0));
51+
}
52+
53+
[TestCase("MD5")]
54+
[TestCase("md5")]
55+
public void ComputeChecksum_MD5_ReturnsExpected(string algorithm)
56+
{
57+
string text = "some text for md5";
58+
string expected = ComputeExpected(algorithm, text);
59+
60+
_sut.ComputeChecksum(algorithm, text, out var actual, out var ticks);
61+
62+
Assert.That(actual, Is.EqualTo(expected));
63+
Assert.That(ticks, Is.GreaterThan(0));
64+
}
65+
66+
[Test]
67+
public void ComputeChecksum_InvalidAlgorithm_ThrowsArgumentException()
68+
{
69+
Assert.Throws<ArgumentException>(() =>
70+
_sut.ComputeChecksum("UNKNOWN", "text", out _, out _));
71+
}
72+
73+
[Test]
74+
public void ComputeChecksum_NullAlgorithm_ThrowsArgumentNullException()
75+
{
76+
Assert.Throws<ArgumentNullException>(() =>
77+
_sut.ComputeChecksum(null!, "text", out _, out _));
78+
}
79+
80+
[Test]
81+
public void ComputeChecksum_NullText_ThrowsArgumentNullException()
82+
{
83+
Assert.Throws<ArgumentNullException>(() =>
84+
_sut.ComputeChecksum("SHA256", null!, out _, out _));
85+
}
86+
*/
87+
}
88+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using OutSystems.ExternalLibraries.SDK;
2+
3+
namespace OutSystems.NetChecksumUtils
4+
{
5+
/// <summary>
6+
/// Computes a hexadecimal checksum for the provided text using the specified algorithm (SHA256, SHA512, MD5, SHA3_256, using the .Net System.Security.Cryptography dll.
7+
/// </summary>
8+
[OSInterface(
9+
Description = "Computes a hexadecimal checksum for the provided text using the specified algorithm (SHA256, SHA512, MD5, SHA3_256, using the .Net System.Security.Cryptography dll.",
10+
IconResourceName = "OutSystems.YAEmailValidator.resources.YAEmailValidator_icon.png"
11+
)]
12+
public interface INetChecksumUtils
13+
{
14+
[OSAction(
15+
Description = "Computes a hexadecimal checksum for the provided text using the specified algorithm.",
16+
IconResourceName = "OutSystems.YAEmailValidator.resources.YAEmailValidator_icon.png"
17+
)]
18+
void ComputeChecksum(
19+
[OSParameterAttribute(Description = "The name of the hashing algorithm to use. Supported values (case-insensitive): \"SHA256\", \"SHA-256\", \"SHA512\", \"SHA-512\", \"MD5\", \"SHA3-256\", \"SHA3_256\".")]
20+
string algorithm,
21+
[OSParameterAttribute(Description = "The text to compute the checksum for. The text is encoded as UTF-8 before hashing.")]
22+
string textToHash,
23+
[OSParameterAttribute(Description = "Output parameter that receives the computed checksum as an uppercase hexadecimal string.")]
24+
out string checksumText,
25+
[OSParameterAttribute(Description = "Output parameter that receives the duration of the hashing operation in ticks.")]
26+
out long operationDuration
27+
);
28+
29+
[OSAction(
30+
Description = "Computes a hexadecimal checksum for the provided text using the specified algorithm.",
31+
IconResourceName = "OutSystems.YAEmailValidator.resources.YAEmailValidator_icon.png"
32+
)]
33+
void VerifyChecksum(
34+
[OSParameterAttribute(Description = "The name of the hashing algorithm to use. Supported values (case-insensitive): \"SHA256\", \"SHA-256\", \"SHA512\", \"SHA-512\", \"MD5\", \"SHA3-256\", \"SHA3_256\".")]
35+
string algorithm,
36+
[OSParameterAttribute(Description = "The name of the hashing algorithm to use. Supported values (case-insensitive): \"SHA256\", \"SHA-256\", \"SHA512\", \"SHA-512\", \"MD5\", \"SHA3-256\", \"SHA3_256\".")]
37+
string text,
38+
[OSParameterAttribute(Description = "The text to compute the checksum for. The text is encoded as UTF-8 before hashing.")]
39+
string existingChecksum,
40+
[OSParameterAttribute(Description = "Output parameter that receives the computed checksum as an uppercase hexadecimal string.")]
41+
out bool isValid,
42+
[OSParameterAttribute(Description = "Output parameter that receives the duration of the hashing operation in ticks.")]
43+
out long operationDuration
44+
);
45+
}
46+
}

0 commit comments

Comments
 (0)