2.1.0 • Published 1 year ago

drupal-hash-v2 v2.1.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Drupal Hash v2

This is a port of the Drupal 7 password hashing algorithms

Usage

npm install drupal-hash-v2
yarn add drupal-hash-v2

Check existing password

const drupalHash = require('drupal-hash-v2');

const clearPassword = 'superpassword';
const passwordHash = '$S$DODRFsy.GX2iSkl2zJ4fsrGRt2S0FOWu0JSA3BqAmSayESbcY3w9';
const isValid = drupalHash.checkPassword(clearPassword, passwordHash);
// returns true or false

Hash new password

const drupalHash = require('drupal-hash-v2');

const newPassword = 'superpassword';
const passwordHash = drupalHash.hashPassword(newPassword);
// returns something like '$S$DODRFsy.GX2iSkl2zJ4fsrGRt2S0FOWu0JSA3BqAmSayESbcY3w9'

Check if an old password needs updated

const drupalHash = require('drupal-hash-v2');

const passwordHash = '$P$DxTIL/YfZCdJtFYNh1Ef9ERbMBkuQ91';
const needsHash = drupalHash.needsNewHash(passwordHash);
// return true or false

Testing

yarn install
yarn test

Credits

This package is an updated version of drupal-hash originally created by wegolook

2.1.0

1 year ago

2.0.0

1 year ago