使用python passlib验证js pbkdf2-sha256哈希

时间:2017-10-07 09:46:51

标签: javascript python sha256 passlib

我使用pbkdf2-sha256在javascript中加密python文件和hashit中的随机字符串,但是使用python passlib验证验证失败了。知道为什么吗?

我的python代码是:

from passlib.hash import pbkdf2_sha256
import os,random,string
t = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in 
range(7))
h = os.popen('node 
D:/mojtaba/repos/restaurant_app/frontend/node_modules/a.js '+t).read()[:-2]
a = pbkdf2_sha256.verify(t,h)
print(a)

和js文件包含:

var pbkdf2 = require('pbkdf2-sha256');
var salt = 'WitFCKH03htDKAVA6L3Xmg';
var algorithm = "pbkdf2-sha256";
var iterations = 29000;
var hashed = pbkdf2(process.argv[2], new Buffer(salt), iterations, 
32).toString('base64');
var finalPass = '$'+algorithm +'$'+ iterations +'$'+  salt +'$'+  hashed;
console.log(finalPass)

,结果总是错误

0 个答案:

没有答案