I know that vB uses Bcrypt and I'm using this bcrypt library:

I never succeed to get matching passwords.(yeah I tweaked the library to use $2y$ prefix in the bcrypt_gensalt method)
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "bcrypt.h"
#include "md5.h"
int main(int argc, char **argv)
{
if(!(argc >= 2 && argc <= 3))
{
std::cerr << "Usage: ./bcrypt_release [password] [hash]" << std::endl;
return EXIT_FAILURE;
}
std::string pw = md5(argv[1]);
char salt[BCRYPT_HASHSIZE];
char hash[BCRYPT_HASHSIZE];
int ret;
ret = bcrypt_gensalt(10, salt);
ret = bcrypt_hashpw(pw.c_str(), salt, hash);
if(argc == 3)
{
ret = bcrypt_checkpw(pw.c_str(), argv[2]);
assert(ret != -1);
std::cout << "pw: " << pw.c_str() << "\nsalt: " << salt << "\nhash: " << hash << "\nMatching passwords: " << (ret ? "[FAIL]" : "[OK]") << std::endl;
}
else if(argc == 2)
{
std::cout << "pw: " << pw.c_str() << "\nsalt: " << salt << "\nhash: " << hash << std::endl;
}
return EXIT_SUCCESS;
}
Code:
$userSuppliedPassword = 'Plain Text Password';
$hashToMatch = 'user->token Column Value';
$options['cost'] = 10;
$options['salt'] = 'user->secret Column Value';
if (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $options['salt']))
{
$options['salt'] = str_replace('+', '.', base64_encode($options['salt']));
}
if ($hashToMatch == password_hash(md5($userSuppliedPassword), PASSWORD_BCRYPT, $options))
{
echo "Woot!<br/>\n";
}else{
echo "Sad Face.<br/>\n";
}
Anyone an idea?






