Skip to content


Repository files navigation


Rust bindings to libsodium.

This repository has been copied to the open-development platform Subspace, you can access it directly by following this link.

To learn more about Subspace, click here.

The rust_sodium crate is no longer maintained by MaidSafe, you should check whether it is actively maintained on Subspace as per the link above, or switch to a modern alternative.

Interested in taking ownership? Contact us at

This project is largely based on sodiumoxide. Some main differences are:

  • this project builds or downloads libsodium by default, favouring a statically-built, fixed version of the native library
  • offers the ability to initialise libsodium with a psuedorandom number generator, allowing for reproducible data to be generated, which can be useful in the context of tests
  • implements a test to ensure the FFI bindings match the native library's interface
  • runs CI tests on Windows (AppVeyor), OS X and Linux (Travis)
Crate Documentation Linux/macOS Windows Issues
Documentation Build Status Build status Stories in Ready
MaidSafe website SAFE Dev Forum SAFE Network Forum

Note for building on Linux

Certain situations may require building libsodium configured with --disable-pie. To enable this, set an environment variable RUST_SODIUM_DISABLE_PIE while building, e.g.


To use your own copy of libsodium

If you already have a copy of libsodium, you can choose to link this rather than having rust_sodium download and build libsodium for you. You should ensure that it is the same version as is specified in VERSION of our file.

Set an environment variable RUST_SODIUM_LIB_DIR to the folder where libsodium exists. A static version of libsodium will be preferred unless you also set RUST_SODIUM_SHARED to any value.

Alternatively, you can use pkgconfig if appropriate to locate libsodium by setting RUST_SODIUM_USE_PKG_CONFIG to any value. In this case, RUST_SODIUM_SHARED has no effect, and generally a shared version of libsodium will be used.


Cross-Compiling for ARM

  1. Install dependencies and toolchain:

    sudo apt update
    sudo apt install build-essential gcc-arm-linux-gnueabihf libc6-armhf-cross libc6-dev-armhf-cross -y
    rustup target add armv7-unknown-linux-gnueabihf
  2. Add the following to a .cargo/config file:

    linker = "arm-linux-gnueabihf-gcc"
  3. Build by running:

    cargo build --release --target armv7-unknown-linux-gnueabihf

Cross-Compiling for 32-bit Linux

  1. Install dependencies and toolchain:

    sudo apt update
    sudo apt install build-essential gcc-multilib -y
    rustup target add i686-unknown-linux-gnu
  2. Build by running:

    cargo build --release --target i686-unknown-linux-gnu


This SAFE Network library is dual-licensed under the Modified BSD (LICENSE-BSD or the MIT license (LICENSE-MIT at your option.


Want to contribute? Great 🎉

There are many ways to give back to the project, whether it be writing new code, fixing bugs, or just reporting errors. All forms of contributions are encouraged!

For instructions on how to contribute, see our Guide to contributing.


This crate is no longer maintained. Looking for maintainers.



BSD-3-Clause, Unknown licenses found

Licenses found






No packages published