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

md5-to-bcrypt-migrator

v1.0.4

Published

A lightweight and seamless Node.js utility to migrate legacy MD5-hashed passwords to modern bcrypt hashes during user login, enhancing application security without user disruption.

Readme

md5-to-bcrypt-migrator

A lightweight Node.js utility to seamlessly migrate legacy MD5-hashed passwords to modern, secure bcrypt hashes during user login — without disrupting user experience.


🚀 Why This Library?

Many legacy systems still store user passwords using MD5, which is insecure by modern standards. This package allows developers to automatically verify an MD5 password and rehash it using bcrypt during a login attempt.

✅ Zero-friction user experience
✅ No need to ask users to reset passwords
✅ One-time migration on login
✅ Lightweight, fast, and simple


📦 Installation

npm install md5-to-bcrypt-migrator
```bash
* Working Example with React.JS is as follows:
import { verifyAndMigrate } from 'md5-to-bcrypt-migrator';

const login = async (inputPassword: string, storedHash: string, hashType: 'md5' | 'bcrypt') => {
 const result = await verifyAndMigrate(inputPassword, storedHash, hashType);

 if (result.success) {
   if (result.migrated) {
     console.log("Password is valid and migrated to bcrypt.");
     console.log("New bcrypt hash:", result.newHash);

     // You should now update the user's password hash in DB to result.newHash
     // and set hashType to "bcrypt" for future logins.
   } else {
     console.log("Password is valid and already bcrypt.");
   }
 } else {
   console.log("Invalid password");
 }
};

📘 API Reference

verifyAndMigrate(inputPassword, storedHash, hashType?)

| Parameter | Type | Required | Description | |----------------|----------|----------|---------------------------------------------------------------------| | inputPassword| string | ✅ | The plaintext password entered by the user | | storedHash | string | ✅ | The stored MD5 or bcrypt hash from your database | | hashType | string | ❌ | Optional, defaults to 'md5'. Use 'md5' or 'bcrypt' |

📦 Returns

A Promise that resolves to an object:

{
  success: boolean;         // true if password matched
  migrated?: boolean;       // true if MD5 matched and was migrated
  newHash?: string;         // newly generated bcrypt hash (if migrated)
  newHashType?: 'bcrypt';   // explicitly mentions new hash type
}
## 🛡️ Security Note

**MD5 is broken**: Never store passwords using MD5 in modern applications.

This library is designed to migrate away from MD5, **not** to encourage its continued use.

✅ Always store passwords using strong hash algorithms like `bcrypt` or `Argon2`.

---

## 🌐 Use Case

This utility is ideal if you're:

- Maintaining a legacy app with MD5-hashed passwords
- Upgrading security without forcing users to reset passwords
- Doing backend work in Node.js

---

## 🛠️ Contributing

Contributions and issues are welcome!  
Please see the [issues page](https://github.com/wa5/md5-to-bcrypt-migrator/issues) or open a pull request.

---

## 📄 License

**ISC License** — see the [LICENSE](./LICENSE) file for details.

---

## 👤 Author

**Waseem Ahmed**  
GitHub: [@wa5](https://github.com/wa5)