MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / hashPassword

Function hashPassword

packages/common/server/crypto.ts:17–30  ·  view source on GitHub ↗
(
  password: string,
  keyLength = 32,
)

Source from the content-addressed store, hash-verified

15 * @returns {string} The salt+hash
16 */
17export async function hashPassword(
18 password: string,
19 keyLength = 32,
20): Promise<string> {
21 return new Promise((resolve, reject) => {
22 // generate random 16 bytes long salt - recommended by NodeJS Docs
23 const salt = generateSalt();
24 scrypt(password, salt, keyLength, (err, derivedKey) => {
25 if (err) reject(err);
26 // derivedKey is of type Buffer
27 resolve(`${salt}.${derivedKey.toString('hex')}`);
28 });
29 });
30}
31
32/**
33 * Compare a plain text password with a salt+hash password

Callers 6

client.tsFile · 0.90
onboarding.tsFile · 0.90
project.tsFile · 0.90
createProjectFunction · 0.90
createClientFunction · 0.90
createMockFunction · 0.90

Calls 2

generateSaltFunction · 0.85
toStringMethod · 0.45

Tested by

no test coverage detected