Skip to content

Instantly share code, notes, and snippets.

@Khuzha
Created March 20, 2021 22:53
Show Gist options
  • Save Khuzha/a864240064b4805a51b70c67315020d8 to your computer and use it in GitHub Desktop.
Save Khuzha/a864240064b4805a51b70c67315020d8 to your computer and use it in GitHub Desktop.
const bcrypt = require('bcrypt');
const src = 'hello world';
const salt = bcrypt.genSaltSync(10);
const hash1 = bcrypt.hashSync(src, salt);
const hash2 = bcrypt.hashSync(src, salt);
console.log(`src = ${src}`);
console.log(`salt = ${salt}\n`);
console.log(`hash 1 = ${hash1}`);
console.log(`hash 2 = ${hash2}\n`);
console.log(`compare 1 = ${bcrypt.compareSync(src, hash1)}`);
console.log(`compare 2 = ${bcrypt.compareSync(src, hash2)}`);
@Khuzha
Copy link
Author

Khuzha commented Mar 20, 2021

Запустил два раза, ниже результаты:

@Khuzha
Copy link
Author

Khuzha commented Mar 20, 2021

src = hello world
salt = $2b$10$cHO7HgdB744ZvkdXy.vdYe

hash 1 = $2b$10$cHO7HgdB744ZvkdXy.vdYeI8XHBqYcYOv2u8mVsb4EUAmDCQJeIiS
hash 2 = $2b$10$cHO7HgdB744ZvkdXy.vdYeI8XHBqYcYOv2u8mVsb4EUAmDCQJeIiS

compare 1 = true
compare 2 = true

@Khuzha
Copy link
Author

Khuzha commented Mar 20, 2021

src = hello world
salt = $2b$10$LoFfv/RCHkVO1leLS8UMwe

hash 1 = $2b$10$LoFfv/RCHkVO1leLS8UMwe.bljq9q5/9H.azm7KLuOxxrQylD0Rwy
hash 2 = $2b$10$LoFfv/RCHkVO1leLS8UMwe.bljq9q5/9H.azm7KLuOxxrQylD0Rwy

compare 1 = true
compare 2 = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment