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

image-password

v0.2.1

Published

Use images as passwords: normalize bytes, hash, and derive keys (Node + browser).

Readme

image-password

Use images as passwords. This library normalizes image bytes from many inputs (Buffer, ArrayBuffer, Blob/File, URL, data URL), hashes them (SHA-256/384/512), and can derive stable keys with PBKDF2 across Node and browsers. Now includes EXIF stripping, input size limits, and timing-safe verification.

Install

npm i image-password

Node 18+ recommended. In Node, remote URL fetching uses undici.

API

import { hashImage, deriveKeyFromImage, bufferToHex, toBase64 } from 'image-password';

// Hash an image input → hex string
const hex = await hashImage(input, { algorithm: 'SHA-256', normalize: 'raw' });

// Derive a key from image bytes using PBKDF2 → Uint8Array
const key = await deriveKeyFromImage(input, {
  algorithm: 'SHA-256',
  iterations: 200_000,
  length: 32,
  salt: 'image-password',
  maxBytes: 10 * 1024 * 1024, // 10MB limit
});

Inputs Supported

  • Buffer, ArrayBuffer, Uint8Array
  • Blob, File (browser)
  • string/URL: remote URL or data: URL

Options and Security Notes

  • normalize: 'exif-stripped' removes JPEG APP1 EXIF and PNG eXIf chunks.
  • maxBytes rejects inputs larger than the given number of bytes (after fetch). Consider setting per your risk appetite.
  • PBKDF2 defaults: 200k iterations, SHA-256, 32 bytes. Tune for your performance and security goals.
  • Use per-user salt (e.g., user ID) and store only the derived key or hash.
  • Use verifyHash(a, b) for timing-safe equality of hex digests.

Examples

// From a file input (browser)
const file = inputEl.files![0];
const loginKey = await deriveKeyFromImage(file, { salt: userId, iterations: 200_000 });

// From a URL
const pwHex = await hashImage('https://example.com/photo.jpg');

// As a data URL
const pwHex2 = await hashImage('data:image/png;base64,iVBORw0KGgo...');

// Timing-safe verify
const ok = verifyHash(pwHex, pwHex2);

Why not pixels?

This library intentionally hashes the original bytes, not decoded pixel buffers, to avoid encoding ambiguities. If you require pixel-based normalization (e.g., resize, format conversion), do that step yourself first and pass the resulting bytes here.

License

MIT