Meyn.Utilities 10.2.0

dotnet add package Meyn.Utilities --version 10.2.0
                    
NuGet\Install-Package Meyn.Utilities -Version 10.2.0
                    
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="Meyn.Utilities" Version="10.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meyn.Utilities" Version="10.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Meyn.Utilities" />
                    
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 Meyn.Utilities --version 10.2.0
                    
#r "nuget: Meyn.Utilities, 10.2.0"
                    
#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 Meyn.Utilities@10.2.0
                    
#: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=Meyn.Utilities&version=10.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Meyn.Utilities&version=10.2.0
                    
Install as a Cake Tool

Meyn.Utilities

NuGet GitHub

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 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. 
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 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.

Version Downloads Last Updated
10.2.0 50 7/29/2026
10.0.1 354 11/23/2025
10.0.0 240 11/23/2025
8.0.1 202 10/25/2025
7.0.0 300 6/28/2025
6.0.0 532 12/16/2023
5.0.0 899 1/28/2023
4.0.0 528 12/25/2022
3.1.0 838 8/11/2022
3.0.0 571 8/11/2022
2.0.0 4,191 7/20/2022
1.0.0 600 7/20/2022