xyToolz 1.0.31

Additional Details

Use newer Version

There is a newer version of this package available.
See the version list below for details.
dotnet add package xyToolz --version 1.0.31
                    
NuGet\Install-Package xyToolz -Version 1.0.31
                    
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="xyToolz" Version="1.0.31" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="xyToolz" Version="1.0.31" />
                    
Directory.Packages.props
<PackageReference Include="xyToolz" />
                    
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 xyToolz --version 1.0.31
                    
#r "nuget: xyToolz, 1.0.31"
                    
#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 xyToolz@1.0.31
                    
#: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=xyToolz&version=1.0.31
                    
Install as a Cake Addin
#tool nuget:?package=xyToolz&version=1.0.31
                    
Install as a Cake Tool
xyHashHelper.cs

Der xyHashHelper bietet robuste und sichere Methoden zum Hashen, Vergleichen und Abspeichern von Passwörtern, Salts und kryptografischen Schlüsseln.

📌 Features

  • 🔐 Salted Hashing via PBKDF2 (Rfc2898DeriveBytes)
  • 🔑 Dynamische Salt-Generierung mit Secure RNG
  • 🌶️ Optionale Pepper-Absicherung via Umgebungsvariable PEPPER
  • 🧮 Unterstützt SHA256 und SHA512
  • 🔁 Sichere Passwortverifikation mit FixedTimeEquals
  • 🧪 Umfangreiches Logging
  • 📦 Kompatibel mit AES-Key-Derivation (z. B. für Verschlüsselung)

🔧 Konfiguration

Option Beschreibung Default
PEPPER Umgebungsvariable für zusätzliche Entropie "Ahuhu"
Iterations Wiederholungen in PBKDF2 100_000
KeyLength256 Keylänge für AES-256 / SHA256 32 Bytes
KeyLength512 Keylänge für SHA512 64 Bytes

📌 Methodenübersicht

Methode Zweck
BuildSaltedHash() Erstellt neuen Salt + Hash im Format salt:hash
VerifyPassword() Vergleicht Password gegen Salt+Hash
BuildKeyFromPassword() Generiert AES-Schlüssel aus Passwort + Salt
GenerateSalt() Erstellt sicheren Salt in gewünschter Länge
HashToBytes() / HashToString() Raw-Hash oder Base64-Hash erzeugen
TryVerifyPassword() (neu) Sicherer Passwort-Vergleich mit out bool

🧪 Beispiel

``csharp // Hash erstellen string password = "MeinSicheresPasswort123!"; string saltedHash = xyHashHelper.BuildSaltedHash(HashAlgorithmName.SHA256, password, out byte[] salt);

// Passwort prüfen bool isCorrect = xyHashHelper.VerifyPassword(HashAlgorithmName.SHA256, password, saltedHash);

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

xyRsa

xyRsa is a reusable, fully static utility class designed for secure handling of JWT (JSON Web Tokens) using RSA encryption in .NET-based Web APIs or desktop applications.
It enables easy generation, validation, and management of JWTs with public/private key cryptography, aligned with modern security practices.


🔐 Features

  • JWT Creation using RS256 and SecurityTokenDescriptor
  • JWT Validation with configurable lifetime and signature checks
  • 🔑 Public/Private Key Loading from PEM-formatted strings
  • 📦 Export Public Key as PEM
  • 🏷️ Issuer & Audience configuration
  • 📜 Full logging of success, failure, and exceptions via xyLog

🧪 Example Usage

``csharp await xyRsa.LoadKeysAsync(publicPem, privatePem); await xyRsa.ConfigureAsync("MyApiIssuer", "MyAudience");

var token = await xyRsa.GenerateJwtAsync(new Dictionary<string, object> { { "sub", "user123" }, { "role", "admin" } }, TimeSpan.FromHours(1));

var principal = await xyRsa.ValidateJwtAsync(token); string pem = await xyRsa.GetPublicKeyAsPemAsync();

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Class: xyFiles

Purpose

Provides a cross-platform, static utility class for file and directory operations such as reading, writing, renaming, and deleting.

Features

  • Directory management: EnsureDirectory, CheckForDirectories
  • File metadata & inspection: Inventory, InventoryNames
  • File I/O: ReadLinesAsync, SaveToFile, LoadFileAsync
  • File manipulation: RenameFileAsync, DeleteFile
  • Binary support: SaveBytesToFileAsync, LoadBytesFromFile

Thread Safety

All methods are static and stateless, ensuring thread safety by design.

Platform Compatibility

Special handling for Android via conditional compilation (#if ANDROID).

Example

``csharp var lines = await xyFiles.ReadLinesAsync("settings.txt");

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.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on xyToolz:

Package Downloads
xyPortHelper

Providing basic operations for ports like: listing open ports and connections open and close ports and connections send messages via TCP or UDP

ExtendedCRUD

CRUD + Pageineering + x

xyAvalonia

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.