npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zaneray/zcrypt

v1.0.1

Published

A simple library for generating salted password hashes and validating plain text passwords against them.

Readme

ZCrypt

A simple library for generating salted password hashes and validating plain text passwords against them.

Overview

ZCrypt uses Node.js's built-in crypto module to perform password hashing using the pbkdf2Sync algorithm with a SHA512 digest. It requires a salt to be provided during initialization, ensuring that the same password does not result in the same hash across different applications.

Installation

Install the package from npm and add it to your package.json:

npm install @zaneray/zcrypt

Usage

Here's how to use ZCrypt to hash and validate passwords.

1. Initialize ZCrypt

First, you need to create an instance of ZCrypt with a salt. The salt should be a securely generated, unique string for your application.

import ZCrypt from '@zaneray/zcrypt';

const salt = 'your-super-secret-and-unique-salt';
const zcrypt = new ZCrypt(salt);

2. Create a Password Hash

Use the createHash method to generate a hash for a user's password. You should store this hash in your database.

const password = 'mySecurePassword123';
const hashedPassword = zcrypt.createHash(password);

console.log(hashedPassword);
// Outputs a 128-character hex string

3. Validate a Password

When a user tries to log in, use the validatePassword method to compare the plain text password they provide with the stored hash.

const loginPassword = 'mySecurePassword123';
const storedHash = 'the-hash-you-saved-in-the-database'; // The output from createHash

const isPasswordCorrect = zcrypt.validatePassword(loginPassword, storedHash);

if (isPasswordCorrect) {
    console.log('Password is correct!');
} else {
    console.log('Incorrect password.');
}

Command-Line Scripts

The package includes two scripts that can be run from the command line for convenience.

generate-pw-hash

This script generates a hashed password using plain text password set in ZCRYPT_PW and the salt set in ZCRYPT_PASSWORD_SALT. It requires two environment variables to be set in you .env file you create from the .env-sample file.

  • ZCRYPT_PASSWORD_SALT: The salt to use for hashing.
  • ZCRYPT_PW: The plain text password to hash.

You can run the script like this:

npm run generate-pw-hash

test

This script runs a test to ensure that the hashing and validation are working correctly. It uses the same environment variables set in your .env file as generate-pw-hash to create a hash and then validates it.

npm test

API

new ZCrypt(salt)

  • salt (String): The salt to be used for hashing.

Creates a new ZCrypt instance.

createHash(password)

  • password (String): The plain text password to hash.

Returns a hex-encoded string of the hashed password.

validatePassword(password, hash)

  • password (String): The plain text password to validate.
  • hash (String): The hash to compare against.

Returns true if the password matches the hash, and false otherwise.