Meyn.Utilities
10.2.0
dotnet add package Meyn.Utilities --version 10.2.0
NuGet\Install-Package Meyn.Utilities -Version 10.2.0
<PackageReference Include="Meyn.Utilities" Version="10.2.0" />
<PackageVersion Include="Meyn.Utilities" Version="10.2.0" />
<PackageReference Include="Meyn.Utilities" />
paket add Meyn.Utilities --version 10.2.0
#r "nuget: Meyn.Utilities, 10.2.0"
#:package Meyn.Utilities@10.2.0
#addin nuget:?package=Meyn.Utilities&version=10.2.0
#tool nuget:?package=Meyn.Utilities&version=10.2.0
Meyn.Utilities
A collection of common utilities and extensions for .NET applications. Targets .NET 10.
Repository: https://github.com/prmeyn/CommonUtilities
Installation
dotnet add package Meyn.Utilities
All public types live under the Meyn.Utilities namespace (HTTP extensions are in Meyn.Utilities.Extensions).
Features
Cryptography Utilities (CryptoUtils)
Provides helper methods for random number generation, hashing, and encoding. Random digits are produced with a cryptographically secure RNG and are uniformly distributed (no modulo bias).
using Meyn.Utilities;
// Generate a cryptographically secure random numeric string of a specific length
string randomNum = CryptoUtils.GetRandomNumber(6); // e.g., "402917"
// Compute SHA-512 hash
string hash = CryptoUtils.ComputeSha512Hash("password123");
// Base64 Encoding/Decoding
string base64 = CryptoUtils.ToBase64("Hello World");
string plain = CryptoUtils.FromBase64(base64);
General Utilities (Utils)
Template Substitution
Replace placeholders in a string with values from a dictionary. Placeholders should be in the format ##Key##. If the template is empty or whitespace, a newline-separated list of the resolved values is returned instead. Passing a null dictionary throws ArgumentNullException.
using Meyn.Utilities;
var template = "Hello ##Name##, welcome to ##City##!";
var args = new Dictionary<string, string>
{
{ "Name", "John" },
{ "City", "New York" }
};
string result = Utils.SubstituteTemplate(template, args);
// Output: "Hello John, welcome to New York!"
HTTP Extensions (HttpContextExtensions)
Get Public IP
Retrieves the client's public IP address from HttpContext. It checks the CF-Connecting-IP (Cloudflare) and X-Forwarded-For headers, then falls back to Connection.RemoteIpAddress, skipping loopback addresses (::1, 127.0.0.1). Returns null when no non-loopback address can be determined.
using Meyn.Utilities.Extensions;
// Inside a Controller or Middleware
string? ipAddress = HttpContext.GetPublicIP();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.11)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Meyn.Utilities:
| Package | Downloads |
|---|---|
|
SMSwitch
Package Description |
|
|
UmbracoMongoTokenManager
Package Description |
|
|
MongoDbTokenManager
Create, store and verify one-time tokens (OTTs) in MongoDB: numeric codes for SMS or GUID tokens for email links, with salted hashing, expiry checks and TTL-based cleanup. |
GitHub repositories
This package is not used by any popular GitHub repositories.