BlazorSodium 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorSodium --version 1.2.0                
NuGet\Install-Package BlazorSodium -Version 1.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="BlazorSodium" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorSodium --version 1.2.0                
#r "nuget: BlazorSodium, 1.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.
// Install BlazorSodium as a Cake Addin
#addin nuget:?package=BlazorSodium&version=1.2.0

// Install BlazorSodium as a Cake Tool
#tool nuget:?package=BlazorSodium&version=1.2.0                

BlazorSodium

BlazorSodium is a simple wrapper over libsodium.js to use in Blazor WASM projects.

This is not compatible with Blazor Server.

Setup

Add to your Program.cs:

builder.Services.AddBlazorSodium();

Initialize the BlazorSodiumService from any component. You only need to do this once for the lifecycle of your application.

For example:

public partial class BlazorSodiumComponent : ComponentBase
{
   [Inject]
   IBlazorSodiumService BlazorSodiumService { get; set; }

   protected override async Task OnInitializedAsync()
   {
      await BlazorSodiumService.InitializeAsync();
   }
}

That is the entirety of the setup. Now use the static wrapper methods from anywhere in your application.

Data types

byte[] as a return value

When a Sodium methods returns byte[] data, you often need to use Array.CopyTo(Array array, int index) to copy the data to an initialized array if you intend to use the data outside of the current scope. Otherwise the byte[] may be garbage collected and your variable will be null.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BlazorSodium:

Package Downloads
AlgorandBlazor_Experimental

Algorand SDK for Blazor (Experimental)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.2 1,413 1/22/2024
1.3.0 199 1/9/2024
1.2.0 1,606 4/1/2023
1.1.0 1,422 11/29/2022
1.0.0 314 11/24/2022