Sodium: A Modern and Easy-to-Use Crypto Library

October 18, 2015

(This article was first published on OpenCPU, and kindly contributed to R-bloggers)

opencpu logo

This week a new package called sodium was released on CRAN. This package implements bindings to libsodium: a modern, easy-to-use software library for encryption, decryption, signatures, password hashing and more.

Libsodium is actually a portable fork of Daniel Bernstein’s famous NaCL crypto library, which provides core operations needed to build higher-level cryptographic tools. It is not intended for implementing standardized protocols such as TLS, SSH or GPG, you still need something like OpenSSL for that. Sodium only supports a limited set of state-of-the-art elliptic curve methods, resulting in a simple but very powerful tool-kit for building secure applications.

Getting started with Sodium

The package includes two nice vignettes to get you started:

If you always wanted to understand how encryption works without getting a degree in computer science, check out the latter. The basic techniques are easy to understand because cryptographers have done a great job at abstracting the mathematical details into simple hash functions and Diffie-Hellman functions.

Installing Sodium

On Windows on OSX simply install the binary packages from CRAN:


On Linux you need sodium shared library which is called libsodium-dev on Debian/Ubuntu and libsodium-devel on Fedora/EPEL. Because this library is relatively young, it is only available for recent versions of these distributions. For Ubuntu 12.04 and 14.04 there are backports available from Launchpad:

sudo add-apt-repository ppa:chris-lea/libsodium
sudo apt-get update
sudo apt-get install libsodium-dev

On CentOS/RHEL you need to activate EPEL before installing libsodium-devel.

To leave a comment for the author, please follow the link and comment on their blog: OpenCPU. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)