CodeLogic.Common 4.5.2-preview.68

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

CodeLogic.Common

NuGet

General-purpose utility toolkit for CodeLogic applications. A broad collection of stateless, thread-safe helpers covering security, ID/password generation, caching, compression, imaging, data (JSON), file handling, type conversion, cron parsing, date/time, strings, web, networking, and reflection.

Operations that can fail return CodeLogic.Core.Results.Result / Result<T> rather than throwing, so callers rarely need try/catch.

Install

dotnet add package CodeLogic.Common

Features

Area Type(s) What it does
Security — hashing CL.Common.Security.Hashing SHA-256/512, MD5 (obsolete), PBKDF2 password hash/verify, salt generation, HMAC-SHA256/512
Security — encryption CL.Common.Security.Encryption AES-256-GCM authenticated encrypt/decrypt (string & bytes) with PBKDF2 key derivation, random key generation
Generators — IDs CL.Common.Generators.IdGenerator GUIDs, sequential, timestamp, random alphanumeric/hex/Base64, URL-safe, NanoID, sortable IDs
Generators — passwords CL.Common.Generators.PasswordGenerator Random passwords, strong passwords, passphrases, PINs, strength estimation
Caching CL.Common.Caching.ICache, MemoryCache Async typed in-process cache with per-entry TTL, prefix removal, count, background eviction
Compression CL.Common.Compression.CompressionHelper GZip, Brotli, and LZ4 (byte arrays) plus GZip-to-Base64 string helpers
Imaging CL.Common.Imaging.CLU_Imaging Resize, crop, format conversion (JPEG/PNG/WebP), thumbnails, dimensions, Base64 — via SkiaSharp
Data — JSON CL.Common.Data.JsonHelper Serialize/deserialize, file I/O, validation, merge, property extraction (System.Text.Json)
Conversion CL.Common.Conversion.TypeConverter Safe Result-based conversion to int/long/double/bool/decimal/DateTime/Guid/enum
File handling CL.Common.FileHandling.FileSystem Async read/write/copy/move/delete, directory create, listing, size, existence
Cron CL.Common.Parser.CronParser, CronExpression Parse/validate 5-field cron and compute the next UTC occurrence
Date/time CL.Common.Time.DateTimeHelper Unix timestamps, ISO 8601, age, business days, boundary helpers, relative strings
Strings CL.Common.Strings.StringHelper, StringValidator Truncate, slug, case conversion, HTML strip; email/URL/phone/IP/GUID validation
Web CL.Common.Web.UrlHelper, HtmlHelper, HttpClientHelper, HttpHeaderHelper URL build/parse/encode, HTML sanitize/encode, typed HTTP requests, header/IP/UA helpers
Networking CL.Common.Networking.NetworkPing, NetworkDns, SubnetCalculator, TraceRoute ICMP ping, DNS lookup, IPv4 subnet math, traceroute
Reflection CL.Common.Assemblies.AssemblyHelper, ReflectionHelper Assembly metadata/loading, type discovery, embedded resources, dynamic property/method access

Quick Start

using CL.Common.Imaging;
using CL.Common.Security;

// Convert any image to WebP
using var input = File.OpenRead("photo.jpg");
var result = CLU_Imaging.ConvertImage(input, ImageFormat.Webp);
if (result.IsSuccess)
    await File.WriteAllBytesAsync("photo.webp", result.Value!.ToArray());

// Hash a string (lowercase hex)
string digest = Hashing.Sha256("my-secret-data");

Security

using CL.Common.Security;

// PBKDF2 password hashing (salt is embedded in the returned string)
string stored = Hashing.HashPassword("hunter2");
bool ok = Hashing.VerifyPassword("hunter2", stored);   // true

// AES-256-GCM authenticated encryption — tampering is detected on decrypt
string cipher = Encryption.EncryptAes("top secret", "passphrase");
string plain  = Encryption.DecryptAes(cipher, "passphrase");

Generators

using CL.Common.Generators;

string id   = IdGenerator.NanoId();              // e.g. "V1StGXR8_Z5jdHi6B-myT"
string sort = IdGenerator.Sortable();            // lexicographically sortable
string pw   = PasswordGenerator.GenerateStrong(20);
string pass = PasswordGenerator.GeneratePassphrase(wordCount: 4);  // "Apple-Bridge-..."
PasswordStrength strength = PasswordGenerator.CalculateStrength(pw);

Caching

using CL.Common.Caching;

ICache cache = new MemoryCache();                       // background eviction loop runs internally
await cache.SetAsync("user:1", userObj, TimeSpan.FromMinutes(5));
var cached = await cache.GetAsync<User>("user:1");      // null if missing/expired
await cache.RemoveByPrefixAsync("user:");

Compression

using CL.Common.Compression;

var packed = CompressionHelper.CompressLz4(payloadBytes);
if (packed.IsSuccess)
    byte[] original = CompressionHelper.DecompressLz4(packed.Value!).Value!;

// Text → Base64 (GZip)
string blob = CompressionHelper.CompressString("a lot of repeated text...").Value!;

JSON & Conversion

using CL.Common.Data;
using CL.Common.Conversion;

string json = JsonHelper.Serialize(new { name = "Ada" }).Value!;   // {"name":"Ada"}
var person  = JsonHelper.Deserialize<Person>(json);

var n = TypeConverter.ToInt("42");          // Result<int>
if (TypeConverter.TryConvert<double>("3.14", out var d)) { /* ... */ }

Cron, Date/Time & Strings

using CL.Common.Parser;
using CL.Common.Time;
using CL.Common.Strings;

var next = CronParser.GetNextOccurrence("0 */6 * * *");   // Result<DateTime> (UTC)
long unix = DateTimeHelper.ToUnixTimestamp(DateTime.UtcNow);
string rel = DateTimeHelper.ToRelativeString(DateTime.UtcNow.AddMinutes(-3)); // "3 minutes ago"

string slug = StringHelper.ToSlug("Hello, World!");       // "hello-world"
bool valid  = StringValidator.IsEmail("a@b.com");

Web & Networking

using CL.Common.Web;
using CL.Common.Networking;

string url = UrlHelper.AppendQuery("https://api.example.com/search",
    new() { ["q"] = "cats", ["page"] = "2" });

using var http = new HttpClient();
var data = await HttpClientHelper.GetJsonAsync<MyDto>(http, url);

var ping = await NetworkPing.PingAsync("example.com");    // Result<PingResult>
var ips  = await NetworkDns.LookupAsync("example.com");   // Result<string[]>

Documentation

Requirements

License

MIT — see LICENSE

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

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
4.6.72 180 6/20/2026
4.6.69-preview 32 6/20/2026
4.5.2 104 5/24/2026
4.5.2-preview.68 58 6/20/2026
4.5.1 158 5/24/2026
4.5.1-preview.56 91 5/24/2026
4.4.2-preview.53 57 5/24/2026
4.4.1 114 5/24/2026
4.0.5 102 5/15/2026
4.0.4 103 5/9/2026
4.0.3 102 5/9/2026
3.2.12 808 4/18/2026
3.2.11 116 4/18/2026
3.2.10 104 4/18/2026
3.2.9 104 4/18/2026
3.2.8 100 4/18/2026
3.2.7 104 4/18/2026
3.2.6 103 4/18/2026
3.2.5 109 4/18/2026
3.2.4 106 4/17/2026
Loading failed

# CL.Common — Changelog

All notable changes to **CodeLogic.Common** are documented here. Versions follow
[Semantic Versioning](https://semver.org/).

## [4.5.2] — 2026-06-20

### Documentation

- Documented the full public surface of the toolkit in the README. Previously only
 imaging, hashing, caching, file handling, compression, and networking were listed;
 the README now also covers **Security** (`Encryption` AES-256-GCM and the `Hashing`
 PBKDF2/HMAC helpers), **Generators** (`IdGenerator`, `PasswordGenerator`),
 **Data** (`JsonHelper`), **Conversion** (`TypeConverter`), **Parser** (`CronParser`),
 **Time** (`DateTimeHelper`), **Strings** (`StringHelper`, `StringValidator`),
 **Web** (`UrlHelper`, `HtmlHelper`, `HttpClientHelper`, `HttpHeaderHelper`),
 the full **Networking** set (`NetworkPing`, `NetworkDns`, `SubnetCalculator`,
 `TraceRoute`), and **Reflection** (`AssemblyHelper`, `ReflectionHelper`).
- Corrected the Quick Start hashing example: the helper is `Hashing.Sha256(...)`
 (no `CLU_Hashing.SHA256` type exists), and clarified that GZip, Brotli, and LZ4
 are all available from `CompressionHelper`. No API changes.

## [4.5.0] — 2026-05-24

### Changed

- **Unified versioning.** All CodeLogic.Libs now share a single version line
 controlled by `version.txt` in the repo root. This is a version alignment
 release — no functional changes to this library.
## [4.0.4] — 2026-04-16

### Changed

- README + manifest refresh across every CodeLogic library for the v4
 baseline. No functional changes vs 4.0.3.
- `LibraryManifest.Version` now reads from the assembly's `AssemblyVersion`
 attribute at runtime instead of a hard-coded string.

## [4.0.2] — 2026-04-09

### Changed

- Aligned with the v4 baseline across all libraries.

## [4.0.0] — 2026-04-09

Major rewrite — republished as v4.0.0 to reset the version line under the
unified v4 baseline. All public APIs refreshed.

### Notes

- Bundles cross-platform native assets transitively for libraries that need
 them (e.g. SkiaSharp for image handling).
- Earlier history is retained in the
 [git log](https://github.com/Media2A/CodeLogic.Libs/commits/main/CL.Common).