Tatum.SignatureGenerator
1.0.1
dotnet add package Tatum.SignatureGenerator --version 1.0.1
NuGet\Install-Package Tatum.SignatureGenerator -Version 1.0.1
<PackageReference Include="Tatum.SignatureGenerator" Version="1.0.1" />
<PackageVersion Include="Tatum.SignatureGenerator" Version="1.0.1" />
<PackageReference Include="Tatum.SignatureGenerator" />
paket add Tatum.SignatureGenerator --version 1.0.1
#r "nuget: Tatum.SignatureGenerator, 1.0.1"
#:package Tatum.SignatureGenerator@1.0.1
#addin nuget:?package=Tatum.SignatureGenerator&version=1.0.1
#tool nuget:?package=Tatum.SignatureGenerator&version=1.0.1
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 typeTwhose fields will be serialized and used in signature generation. Cannot be null or default.
Return Value
- Returns a
stringrepresenting the computed signature.
Exceptions
ArgumentException: Thrown ifsecretis null, empty, or ifdatais 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
ComputeSignaturefunction (not included in this snippet). Ensure this function is correctly implemented for hash computation.
Author
TatumBank
kehinde.aregbesola@tatumbank.com
| Product | Versions 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. |
-
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.
For installation and usage instructions, see the README.md file.