How can I verify a cryptographic hash created by Python's Passlib using Node.js? -


i have backend application written in python used content managers of site. users' passwords hashed using passlib's pbkdf2_sha512 function. began develop frontend application decided use nodejs react ux reasons.

now problem can't figure out how can verify passwords hashed passlib using nodejs authenticating users. passlib's implementation seems specific me , i'm not crypto stuff figure out.

i have mcf know algorithm , digest type, salt, number of iterations , key length. how can verify output passlib in node? should rather choose algorithm better supported both platforms?

ok, turned sha512_crypt instead , found nice library node called sha512crypt-node. readme contains example both python , node, needed. here's little example ppl. using these platforms:

python:

from passlib.hash import sha512_crypt  orig = "password" h = sha512_crypt.encrypt(orig) print("hash", h) # h eg. $6$rounds=100000$5yntxatkh4b1pljp$3qqjvifjrbitakj.wkaw1woacfiprajjp2u/b3bigw4m8ovi8x0tgw1bb63dnqwmul1uyndbcto3twgrj6ehh1  okay = sha512_crypt.verify(orig, h) print("verified", okay) 

node:

var sha512crypt = require("sha512crypt-node").sha512crypt;  // orighash hash generated passlib     var orighash = "$6$rounds=100000$5yntxatkh4b1pljp$3qqjvifjrbitakj.wkaw1woacfiprajjp2u/b3bigw4m8ovi8x0tgw1bb63dnqwmul1uyndbcto3twgrj6ehh1",     parts = orighash.split('$'),     rounds = parts[2],     salt = '$' + parts[1] + '$' + rounds + '$' + parts[3],     password = "password";  var hash = sha512crypt(password, salt); console.log("verified", hash === orighash); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -