Bcryptjs x Bun.hash

46 Views Asked by At

I'm working on a project in Bun based on a Moodle foundation, in PostgreSQL. The stored password hash is generated using the password_hash function (PHP) using the bcrypt algorithm.

Initially, I tried to use Bun's hash library to compare the password sent by the request and the stored hash, but with Bun it doesn't work at all. On the other hand, I tested it with the compare function of the bcryptjs library and succeeded in the endeavor.

With Bun, I tested the following, and it didn't match:

const isMatch = await Bun.password.verify(password, hash);

With bcryptjs, I tested with the following code and it worked:

const isMatch = await bcrypt.compare(password, hash)

Is it a bug in Bun or is it my mistake?

0

There are 0 best solutions below