mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
consolidate build scripts, reorganize source into src/ directory, fix favicon injection
This commit is contained in:
26
src/shims/crypto/scrypt.js
Normal file
26
src/shims/crypto/scrypt.js
Normal file
@@ -0,0 +1,26 @@
|
||||
export function scrypt(password, salt, keylen, options, callback) {
|
||||
if (typeof options === "function") {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
const N = options?.N || 32768;
|
||||
const r = options?.r || 8;
|
||||
const p = options?.p || 1;
|
||||
|
||||
if (window.scrypt && window.scrypt.scrypt) {
|
||||
const pwBytes =
|
||||
typeof password === "string"
|
||||
? new TextEncoder().encode(password)
|
||||
: password;
|
||||
const saltBytes =
|
||||
typeof salt === "string" ? new TextEncoder().encode(salt) : salt;
|
||||
|
||||
window.scrypt
|
||||
.scrypt(pwBytes, saltBytes, N, r, p, keylen)
|
||||
.then((result) => callback(null, new Uint8Array(result)))
|
||||
.catch((err) => callback(err));
|
||||
} else {
|
||||
callback(new Error("scrypt not available"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user