All Projects → ranisalt → Node Argon2

ranisalt / Node Argon2

Licence: mit
Node.js bindings for Argon2 hashing algorithm

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Node Argon2

Argon2 Jvm
Argon2 Binding for the JVM
Stars: ✭ 245 (-75.69%)
Mutual labels:  hashing, password, argon2
Password4j
Password4j is a user-friendly cryptographic library that supports Argon2, Bcrypt, Scrypt, PBKDF2 and various cryptographic hash functions.
Stars: ✭ 124 (-87.7%)
Mutual labels:  hashing, password, argon2
Lazysodium Android
An Android implementation of the Libsodium cryptography library. For the lazy dev.
Stars: ✭ 69 (-93.15%)
Mutual labels:  hashing, encryption, argon2
OormiPass
Free open source cross platform password manager
Stars: ✭ 50 (-95.04%)
Mutual labels:  crypto, encryption, password
Covertutils
A framework for Backdoor development!
Stars: ✭ 424 (-57.94%)
Mutual labels:  encryption, crypto
S2n Tls
s2n : an implementation of the TLS/SSL protocols
Stars: ✭ 4,029 (+299.7%)
Mutual labels:  encryption, crypto
Featherpasswordmanager
Highly portable extremely light-weight password manager that stores all your passwords in a local encrypted file.
Stars: ✭ 39 (-96.13%)
Mutual labels:  encryption, password
Crypto Hash
Tiny hashing module that uses the native crypto API in Node.js and the browser
Stars: ✭ 501 (-50.3%)
Mutual labels:  hashing, crypto
Purse
GPG asymmetric (YubiKey) password manager
Stars: ✭ 313 (-68.95%)
Mutual labels:  encryption, password
Swifty
🔑 Free Offline Password Manager
Stars: ✭ 496 (-50.79%)
Mutual labels:  encryption, password
Securefs
Filesystem in userspace (FUSE) with transparent authenticated encryption
Stars: ✭ 518 (-48.61%)
Mutual labels:  encryption, crypto
Constellation
Peer-to-peer encrypted message exchange
Stars: ✭ 365 (-63.79%)
Mutual labels:  encryption, crypto
Pick
A secure and easy-to-use CLI password manager for macOS and Linux
Stars: ✭ 359 (-64.38%)
Mutual labels:  crypto, password
Upash
🔒Unified API for password hashing algorithms
Stars: ✭ 484 (-51.98%)
Mutual labels:  hashing, password
Buttercup Core
🎩 The mighty NodeJS password vault
Stars: ✭ 340 (-66.27%)
Mutual labels:  encryption, password
Securitydriven.inferno
✅ .NET crypto done right. Professionally audited.
Stars: ✭ 501 (-50.3%)
Mutual labels:  encryption, crypto
Virgil Crypto Php
Virgil PHP Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
Stars: ✭ 22 (-97.82%)
Mutual labels:  encryption, crypto
Acra
Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
Stars: ✭ 726 (-27.98%)
Mutual labels:  encryption, crypto
Halite
High-level cryptography interface powered by libsodium
Stars: ✭ 933 (-7.44%)
Mutual labels:  encryption, argon2
Featherduster
An automated, modular cryptanalysis tool; i.e., a Weapon of Math Destruction
Stars: ✭ 876 (-13.1%)
Mutual labels:  encryption, crypto

node-argon2

Financial contributors on Open Collective Build status NPM package Coverage status Code Quality Dependencies

Bindings to the reference Argon2 implementation.

Want to use it on command line? Instead check node-argon2-cli.

Usage

It's possible to hash using either Argon2i (default), Argon2d and Argon2id, and verify if a password matches a hash.

To hash a password:

const argon2 = require('argon2');

try {
  const hash = await argon2.hash("password");
} catch (err) {
  //...
}

To see how you can modify the output (hash length, encoding) and parameters (time cost, memory cost and parallelism), read the wiki

To verify a password:

try {
  if (await argon2.verify("<big long hash>", "password")) {
    // password match
  } else {
    // password did not match
  }
} catch (err) {
  // internal failure
}

Migrating from another hash function

See this article on the wiki for steps how to migrate your existing code to Argon2. It's easy!

TypeScript Usage

A TypeScript type declaration file is published with this module. If you are using TypeScript >= 2.0.0 that means you do not need to install any additional typings in order to get access to the strongly typed interface. Simply use the library as mentioned above. This library uses Promises, so make sure you are targeting ES6+, including the es2015.promise lib in your build, or globally importing a Promise typings library.

Some example tsconfig.json compiler options:

{
    "compilerOptions": {
        "lib": ["es2015.promise"]
    }
}

or

{
    "compilerOptions": {
        "target": "es6"
    }
}
import * as argon2 from "argon2";

const hash = await argon2.hash(..);

Differences from node-argon2-ffi

The interface of both are very similar, notably node-argon2-ffi splits the argon2i and argon2d function set, but this module also has the argon2id option, which node-argon2-ffi does not support. Also, while node-argon2-ffi suggests you promisify crypto.randomBytes, node-argon2 library does that internally.

node-argon2 is much lighter than node-argon2-ffi, at 184 KB for [email protected] against 2.56 MB for [email protected] Performance-wise, the libraries are equal. You can run the same benchmark suite if you are curious, but both can perform around 130 hashes/second on an Intel Core i5-4460 @ 3.2GHz with default options.

This library is implemented natively, meaning it is an extension to the node engine. Thus, half of the code are C++ bindings, the other half are Javascript functions. node-argon2-ffi uses ffi, a mechanism to call functions from one language in another, and handles the type bindings (e.g. JS Number -> C++ int).

Prebuilt Binaries

node-argon2 provides prebuilt binaries from v0.26.0 onwards. They are built per release using GitHub Actions.

The current prebuilt binaries are built (and tested) with the following matrix:

  1. Node 10.x, 12.x, 13.x
  2. Ubuntu 16.04, Alpine Linux, Windows Server 2019, macOS Catalina 10.15

If your plaform is below the above requirements, you can follow the Before Installing section below to manually compile from source. It is also always recommended to build from source to ensure consistency of the compiled module.

Before Installing

You can skip this section if the prebuilt binaries work for you.

You MUST have a node-gyp global install before proceeding with install, along with GCC >= 5 / Clang >= 3.3. On Windows, you must compile under Visual Studio 2015 or newer.

node-argon2 works only and is tested against Node >=10.0.0.

OSX

To install GCC >= 5 on OSX, use homebrew:

$ brew install gcc

Once you've got GCC installed and ready to run, you then need to install node-gyp, you must do this globally:

$ npm install -g node-gyp

Finally, once node-gyp is installed and ready to go, you can install this library, specifying the GCC or Clang binary to use:

$ CXX=g++-6 npm install argon2

NOTE: If your GCC or Clang binary is named something different than g++-6, you'll need to specify that in the command.

FAQ

How do I manually rebuild the binaries?
$ npx node-pre-gyp rebuild -C ./node_modules/argon2

Run node-pre-gyp instead of node-gyp because node-argon2's binding.gyp file relies on variables from node-pre-gyp.

You can omit npx if you have a global installation of node-pre-gyp, otherwise prefixing npx will use the local one in ./node_modules/.bin

How do I skip installing prebuilt binaries and manually compile from source?

You can do either of the two methods below:

  1. Force build from source on install.
$ npm install argon2 --build-from-source
  1. Ignore node-argon2 install script and build manually.
$ npm install argon2 --ignore-scripts
$ npx node-pre-gyp rebuild -C ./node_modules/argon2

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

Work licensed under the MIT License. Please check P-H-C/phc-winner-argon2 for license over Argon2 and the reference implementation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].