libsodium for .NET can be installed as follows:
$ dotnet add package Sodium.Core --version 1.4.1-preview.1
The Sodium.Core package is intended to run on all supported versions of .NET on the following platforms:
-x64 |
-x86 |
-arm64 |
-arm |
|
|---|---|---|---|---|
android- |
✓ | ✓ | ✓ | ✓ |
ios- |
✓ | |||
linux- |
✓ | ✓ | ✓ | |
linux-musl- |
✓ | ✓ | ✓ | |
maccatalyst- |
✓ | ✓ | ||
osx- |
✓ | ✓ | ||
tvos- |
✓ | |||
win- |
✓ | ✓ | ✓ |
Please note:
-
On Windows, the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 is required. This is part of Visual Studio and the .NET SDK but might not be present on a clean Windows installation.
-
The AES-GCM implementation in libsodium is hardware-accelerated and may not be available on all architectures. Support can be determined at runtime using the static
IsAvailableproperty of theSodium.SecretAeadAesclass.
Sodium.Core 1.4.1-preview.1 has been tested to run on the following platforms and .NET versions at the time of release:
| OS | Version | Architecture | .NET |
|---|---|---|---|
| Windows Server | 10.0.26100 | x64 | 10.0.5 / 9.0.14 |
| macOS | 15.7 | arm64 | 10.0.5 / 9.0.14 |
| Alpine Linux | 3.23 | x64 | 10.0.5 |
| Ubuntu | 24.04 | x64 | 10.0.5 / 9.0.14 |
The other supported platforms should work as well, but have not been tested.
Below are some frequently asked questions:
Q: What causes a System.DllNotFoundException: Unable to load shared
library 'libsodium' or one of its dependencies. when using libsodium for .NET?
A: This exception can occur if the operating system or architecture is not
supported, or if the Visual C++ Redistributable has not been installed on a
Windows system. Please refer to the Supported Platforms
section above.
Q: Is libsodium for .NET still actively developed?
A: No, libsodium-core is now in maintenance mode. While bug fixes and
compatibility updates for new .NET versions will continue, no new features or
enhancements are being added. For actively developed .NET libsodium bindings,
please see
libsodium.org.