When using the bcrypt library on npm is that it’s limited to a max length of 72 characters. When a null character (ASCII 0) ends up in the password somehow, everything after that is ignored because the underlying implementation uses c-strings. Problem is solve simply by hashing passwords with a digest algorithm and encode with base64 before hashing with bcrypt.
var bcrypt = require('bcrypt')
var crypto = require('crypto')
var _hashFunction = (_password) => crypto.createHash('sha384')
.update(_password)
.digest()
.toString('base64')
const password = _hashFunction('123456')
bcrypt.hash(password, 12).then(console.log)