@eckidevs/cf-pbkdf2

1.0.2 • Public • Published

CloudFlare safe PBKDF2 hashing

Hash a password on CloudFlare Workers using PBKDF2 with a salt and a work factor of 100,000 iterations. Works with Node.js and Bun too. It generates a 96 char padded hex string and uses SHA-256 for the digest.

Installation

bun add @eckidevs/cf-pbkdf2 # or npm, pnpm etc.

Usage

import { hash, verify } from '@eckidevs/cf-pbkdf2';
const hashedPassword = await hash('password');

if (await verify('password', hashedPassword)) {
  console.log('Password is correct');
} else {
  console.log('Password is incorrect');
}

CJS Usage

const { hash, verify } = require('@eckidevs/cf-pbkdf2');
hash('password').then(hashedPassword => {
  verify('password', hashedPassword).then(isCorrect => {
    if (isCorrect) {
      console.log('Password is correct');
    } else {
      console.log('Password is incorrect');
    }
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i @eckidevs/cf-pbkdf2

Weekly Downloads

4

Version

1.0.2

License

MIT

Unpacked Size

7.94 kB

Total Files

7

Last publish

Collaborators

  • eckidevs