chore: restart the repository with a clean history
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
This commit is contained in:
438 files changed
+45070
No files matched your search
@@ -0,0 +1,24 @@
|
||||
const crypto = require("node:crypto");
|
||||
|
||||
const KEY_LENGTH = 64;
|
||||
const SCRYPT_OPTIONS = { N: 16384, r: 8, p: 1 };
|
||||
|
||||
const scrypt = (password, salt, length) => new Promise((resolve, reject) => {
|
||||
crypto.scrypt(password, salt, length, SCRYPT_OPTIONS, (err, derived) => err ? reject(err) : resolve(derived));
|
||||
});
|
||||
|
||||
const hashPassword = password => {
|
||||
const salt = crypto.randomBytes(16);
|
||||
const hash = crypto.scryptSync(password, salt, KEY_LENGTH, SCRYPT_OPTIONS);
|
||||
return `scrypt$${salt.toString("hex")}$${hash.toString("hex")}`;
|
||||
};
|
||||
|
||||
const verifyPassword = async (password, stored) => {
|
||||
const [scheme, saltHex, hashHex] = String(stored || "").split("$");
|
||||
if (scheme !== "scrypt" || !saltHex || !hashHex) return false;
|
||||
const expected = Buffer.from(hashHex, "hex");
|
||||
const actual = await scrypt(String(password), Buffer.from(saltHex, "hex"), expected.length);
|
||||
return crypto.timingSafeEqual(actual, expected);
|
||||
};
|
||||
|
||||
module.exports = { hashPassword, verifyPassword };
|
||||
Reference in new issue
Block a user