mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 04:27:59 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
interface Result {
|
||||
password: Uint8Array;
|
||||
rounds: number;
|
||||
salt: Uint8Array;
|
||||
}
|
||||
export declare function pbkdf2Encode(passphrase?: string | Uint8Array, salt?: Uint8Array, rounds?: number, onlyJs?: boolean): Result;
|
||||
export {};
|
||||
@@ -0,0 +1,16 @@
|
||||
import { pbkdf2 as pbkdf2Js } from '@noble/hashes/pbkdf2';
|
||||
import { sha512 } from '@noble/hashes/sha512';
|
||||
import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
|
||||
import { isReady, pbkdf2 } from '@pezkuwi/wasm-crypto';
|
||||
import { randomAsU8a } from '../random/asU8a.js';
|
||||
export function pbkdf2Encode(passphrase, salt = randomAsU8a(), rounds = 2048, onlyJs) {
|
||||
const u8aPass = u8aToU8a(passphrase);
|
||||
const u8aSalt = u8aToU8a(salt);
|
||||
return {
|
||||
password: !hasBigInt || (!onlyJs && isReady())
|
||||
? pbkdf2(u8aPass, u8aSalt, rounds)
|
||||
: pbkdf2Js(sha512, u8aPass, u8aSalt, { c: rounds, dkLen: 64 }),
|
||||
rounds,
|
||||
salt
|
||||
};
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { pbkdf2Encode } from './encode.js';
|
||||
@@ -0,0 +1 @@
|
||||
export { pbkdf2Encode } from './encode.js';
|
||||
Reference in New Issue
Block a user