Skip to content

Commit

Permalink
Argon2id generate salt
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Shapkarin committed Mar 12, 2022
1 parent 43aad32 commit 663d39c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/crypto/src/libsodium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import { isNonNullObject } from "@cosmjs/utils";
import sodium from "libsodium-wrappers";

import { Random } from './random'

export interface Argon2idOptions {
/** Output length in bytes */
readonly outputLength: number;
Expand Down Expand Up @@ -36,10 +38,11 @@ export function isArgon2idOptions(thing: unknown): thing is Argon2idOptions {
export class Argon2id {
public static async execute(
password: string,
salt: Uint8Array,
saltInput: Uint8Array,
options: Argon2idOptions,
): Promise<Uint8Array> {
await sodium.ready;
const salt: Uint8Array = saltInput || Random.getBytes(16);
return sodium.crypto_pwhash(
options.outputLength,
password,
Expand Down

0 comments on commit 663d39c

Please sign in to comment.