I try to use PBKDF2 but each way I get a different result. Can you tell me what the problem is?
"use strict";
const pbkdf2 = require("pbkdf2"); // npm i pbkdf2
const sha1 = require("sha1"); // npm i sha1
const y = pbkdf2.pbkdf2Sync(
"toto",
"toto",
1000,
8 * 10,
"sha512"
)
.slice(0, 10)
.toString("base64")
;
console.log("y =", y); // X7AxWzPOJiXvfg==
xAeOzSOt1+xNmA==
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
SELECT encode(
PBKDF2(
'toto',
'toto',
1000,
10,
'sha512'
),
'base64'
);
-- ybQxw9hGrIkkXA==
Thank you in advance!
Thank you for your answer AK X.
The link https://github.com/brycx/Test-Vector-Generation/blob/master/PBKDF2/pbkdf2-hmac-sha2-test-vectors.md was very helpful.
The function I was using in postgres was not good, this one seems to work: PBKDF2 function in PostgreSQL.