Tatum.SignatureGenerator 1.0.1

dotnet add package Tatum.SignatureGenerator --version 1.0.1
                    
NuGet\Install-Package Tatum.SignatureGenerator -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tatum.SignatureGenerator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tatum.SignatureGenerator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Tatum.SignatureGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tatum.SignatureGenerator --version 1.0.1
                    
#r "nuget: Tatum.SignatureGenerator, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tatum.SignatureGenerator@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tatum.SignatureGenerator&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Tatum.SignatureGenerator&version=1.0.1
                    
Install as a Cake Tool

GenerateSignature Method

Overview

The GenerateSignature<T> method is a utility function designed for generating a digital signature based on the provided secret key and data. It serializes the data's field values, concatenates them into a string, and computes a signature using a cryptographic hashing function.

Installation

This method is included in a class library that is distributed as a NuGet package. To install the package, use the following command:

Install-Package Tatum.SignatureGenerator

Usage

Method Signature

public static string GenerateSignature<T>(string secret, T data)

Parameters

  • secret (string): A secret key used for generating the signature. Cannot be null or empty.
  • data (T): An object of type T whose fields will be serialized and used in signature generation. Cannot be null or default.

Return Value

  • Returns a string representing the computed signature.

Exceptions

  • ArgumentException: Thrown if secret is null, empty, or if data is null/default.
  • Exception: Any unexpected errors encountered during execution are rethrown.

Example Usage

using Signature.Services; // Ensure you include the correct namespace

class SampleData
{
    public string Name = "John";
    public int Age = 30;
}

class Program
{
    static void Main()
    {
        string secretKey = "my-secret-key";
        SampleData data = new SampleData();

        // Ensure correct class reference
        string signature = Signatures.GenerateSignature(secretKey, data);
        Console.WriteLine($"Generated Signature: {signature}");
    }
}

Notes

  • The method uses reflection to retrieve public and non-public instance fields of the provided data type T.
  • The field values are concatenated into a single string before generating the signature.
  • The signature computation is performed using an external ComputeSignature function (not included in this snippet). Ensure this function is correctly implemented for hash computation.

Author

TatumBank
kehinde.aregbesola@tatumbank.com

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 206 2/27/2025
1.0.0 176 2/26/2025
0.9.0 210 4/4/2025

For installation and usage instructions, see the README.md file.