Soenneker.Extensions.Arrays.Bytes 4.0.66

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.Arrays.Bytes

UTF-8 decoding, hexadecimal and Base64 encoding, MemoryStream wrapping, and null/empty checks for byte arrays and read-only byte spans.

Installation

dotnet add package Soenneker.Extensions.Arrays.Bytes

Text and binary encodings

using System.Text;
using Soenneker.Extensions.Arrays.Bytes;

byte[] bytes = Encoding.UTF8.GetBytes("hello");

string text = bytes.ToStr();              // "hello"
string hex = bytes.ToHex();               // "68656C6C6F"
string lowerHex = bytes.ToHexLower();     // "68656c6c6f"
string base64 = bytes.ToBase64String();   // "aGVsbG8="

ToStr() decodes with .NET's default UTF-8 encoding behavior. Invalid byte sequences are replaced with the Unicode replacement character; this method does not reject malformed UTF-8. Use a strict UTF8Encoding instance when invalid input must fail.

ToHex() and ToHexLower() produce two characters per byte with no prefix or separators. ToBase64String() produces standard padded Base64, not Base64URL. Empty inputs produce an empty string. These methods encode data; they do not encrypt, hash, compress, authenticate, or hide it.

The UTF-8 and Base64 methods also have ReadOnlySpan<byte> overloads. Returned strings are allocations even when the source is a span.

Stream wrapping

byte[] buffer = [1, 2, 3];

using MemoryStream stream = buffer.ToStream();

ToStream() returns a writable, non-expandable stream backed by the original array with Position == 0. Writing within its existing length changes buffer; changing buffer is visible through the stream. Writing past capacity throws. Disposing the stream does not clear or dispose the byte array.

Copy the data first when the stream and caller must not share mutations:

using MemoryStream isolated = buffer.ToArray().ToStream();

Empty checks and nulls

byte[]? optional = null;
bool empty = optional.IsEmpty(); // true

IsEmpty() is the only nullable-array API and returns true for null or zero length. The conversion methods require a non-null receiver; a null array results in NullReferenceException.

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.
  • net10.0

    • No dependencies.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on Soenneker.Extensions.Arrays.Bytes:

Package Downloads
Soenneker.Extensions.Generic

A collection of useful T (generic) extension methods

Soenneker.Utils.SHA3

A utility library for SHA-3 hashing

Soenneker.GitHub.Repositories.Secrets

Lists and manages GitHub Actions repository secrets

Soenneker.Hashing.Blake3

A high-performance .NET library for BLAKE3 hashing and constant-time verification. Pure C# with optional SIMD acceleration (AVX2 on x64, NEON on ARM).

Soenneker.Hashing.Argon2

A utility library for Argon2 hashing and verification

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.66 9,694 8/30/2026
4.0.65 459 8/29/2026
4.0.64 150 8/29/2026
4.0.63 12,134 8/25/2026
4.0.62 312,875 7/27/2026
4.0.61 181,862 7/16/2026
4.0.60 240,792 6/18/2026
4.0.59 177,189 6/9/2026
4.0.58 68,881 6/5/2026
4.0.57 127 6/5/2026
4.0.56 294,975 4/22/2026
4.0.55 258,245 3/12/2026
4.0.54 3,117 3/12/2026
4.0.53 137 3/12/2026
4.0.52 7,248 3/12/2026
4.0.51 91,201 3/10/2026
4.0.50 46,197 3/9/2026
4.0.49 147 3/9/2026
4.0.48 136 3/9/2026
4.0.47 99,416 3/4/2026
Loading failed

Document byte array conversion semantics