drupal-hash-v2
v2.1.0
Published
JavaScript implementation of the hashing algorithm used in Drupal
Downloads
263
Readme
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