Last active
July 16, 2019 00:59
-
-
Save miguelmota/134d8403e512ed70e676175c17bddc27 to your computer and use it in GitHub Desktop.
JavaScript extract salt from bcrypt hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the salt is the first 22 characters after the third '$' | |
// https://en.wikipedia.org/wiki/Bcrypt | |
const hash = '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy' | |
const salt = hash.split('$')[3].substr(0, 22) | |
console.log(salt) // N9qo8uLOickgx2ZMRZoMye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment