Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Cryptography
  3. js-nacl

js-nacl

JavaScript

A pure-JavaScript high-level API wrapper for Emscripten-compiled libsodium cryptographic routines.

Visit WebsiteGitHubGitHub
493 stars47 forks0 contributors

What is js-nacl?

js-nacl is a JavaScript library that provides a high-level API to libsodium cryptographic functions, compiled via Emscripten. It allows developers to perform secure operations like encryption, digital signatures, and hashing directly in JavaScript environments without needing native bindings. The library solves the problem of accessing reliable, modern cryptography in pure JavaScript for both browser and Node.js applications.

Target Audience

JavaScript developers who need to implement cryptography in web or Node.js applications without relying on native modules or server-side processing. It's particularly useful for projects requiring end-to-end encryption, secure messaging, or data integrity verification.

Value Proposition

Developers choose js-nacl because it offers a clean, well-documented JavaScript interface to the battle-tested libsodium library, ensuring cryptographic correctness. Its pure-JavaScript nature eliminates compilation and compatibility issues across platforms, while providing a comprehensive set of modern cryptographic primitives.

Overview

Pure-Javascript High-level API to Emscripten-compiled libsodium routines. -- MOVED TO https://git.leastfixedpoint.com/tonyg/js-nacl

Use Cases

Best For

  • Adding end-to-end encryption to web applications
  • Implementing secure digital signatures in JavaScript
  • Building cryptographic tools that run in browsers
  • Creating cross-platform Node.js and browser crypto modules
  • Prototyping cryptographic protocols without native dependencies
  • Educational projects demonstrating NaCl/libSodium APIs in JavaScript

Not Ideal For

  • Projects requiring peak cryptographic performance: Since js-nacl runs in JavaScript via Emscripten, it may be slower than native libsodium bindings or WebAssembly-optimized alternatives.
  • Applications with stringent memory limits: Each module instance consumes significant heap memory, and the README warns of potential memory leaks, making it unsuitable for memory-constrained environments like IoT devices or low-end mobile browsers.
  • Teams seeking high-level, opinionated crypto APIs: js-nacl closely mirrors the low-level NaCl API, which can be complex for developers unfamiliar with cryptographic details, compared to libraries with simpler abstractions.
  • Legacy browser support: The library depends on modern APIs like window.crypto.getRandomValues and has known issues with older Safari versions, limiting its use in environments requiring broad compatibility.

Pros & Cons

Pros

Pure JavaScript Cross-Platform

Wraps Emscripten-compiled libsodium, eliminating native dependencies and enabling consistent crypto operations in both browsers and Node.js without compilation hassles, as highlighted in the README's cross-platform support.

Comprehensive Primitive Suite

Offers a full range of libsodium functions including crypto_box, crypto_sign, and hashing, based on modern algorithms like Ed25519, ensuring robust security for various use cases.

Strict Data Type Enforcement

Enforces separation between strings and Uint8Arrays with encoding utilities like encode_utf8 and decode_utf8, reducing common bugs in crypto implementations by handling binary data correctly.

Well-Documented API

The README provides extensive examples, configuration options, and warnings, such as detailed usage for crypto_box and nonce handling, making it easier for developers to implement correctly.

Cons

Memory Intensive and Leak-Prone

Each instantiation creates a private heap that may not be efficiently garbage collected, and the README acknowledges memory leak issues that require careful management and testing.

Browser Compatibility Caveats

Requires window.crypto.getRandomValues and has documented failures in Safari 5.1.x, limiting its use in older or restricted environments without fallbacks.

Cumbersome Instantiation Model

The API uses a callback or promise-based instantiation with configuration dictionaries, adding complexity compared to simpler synchronous libraries, as noted in the version history with API changes.

Deprecated Function Names

The library has undergone API changes, with deprecated aliases like crypto_sign_keypair_from_seed still present but slated for removal, risking future breaking changes for existing code.

Frequently Asked Questions

Quick Stats

Stars493
Forks47
Contributors0
Open Issues5
Last commit4 years ago
CreatedSince 2013

Tags

#web-security#encryption#nodejs#digital-signatures#javascript#cryptography#public-key-cryptography#browser#hash-functions#libsodium

Built With

E
Emscripten
l
libSodium
J
JavaScript

Links & Resources

Website

Included in

Cryptography6.8k
Auto-fetched 18 hours ago

Related Projects

crypto-jscrypto-js

JavaScript library of crypto standards.

Stars16,392
Forks2,499
Last commit1 year ago
node.bcrypt.jsnode.bcrypt.js

bcrypt for NodeJs

Stars7,804
Forks552
Last commit3 months ago
sjclsjcl

[DEPRECATED] Stanford Javascript Crypto Library

Stars7,205
Forks995
Last commit4 months ago
jsencryptjsencrypt

A tiny (18.5 kB gzip), zero-dependency, Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.

Stars6,810
Forks2,004
Last commit3 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub