How to use the argon2.argon2id function in argon2

To help you get started, we’ve selected a few argon2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simonepri / phc-argon2 / index.js View on Github external
});

/**
 * Supported Argon2 variants.
 * Argon2 currently has three modes:
 * - d: Argon2d data-dependent.
 * - i: Argon2i data-independent.
 * - id: Argon2id a mix of the two.
 * See https://crypto.stackexchange.com/a/49969
 * @private
 * @type {Object}
 */
const variants = Object.freeze({
  i: argon2.argon2i,
  d: argon2.argon2d,
  id: argon2.argon2id
});

/**
 * Supported Argon2 versions.
 * @private
 * @type {number[]}
 */
const versions = [
  0x10, // 1.0 (16)
  0x13 // 1.3 (19)
];

/**
 * Computes the hash string of the given password in the PHC format using argon2
 * package.
 * @public
github ArkEcosystem / core / commander / commands / configure-webhooks / index.js View on Github external
module.exports = async () => {
  const response = await prompts(questions, { onCancel })

  let config = readConfig('webhooks')
  config.enabled = response.enabled
  config.password = await argon2.hash(response.password, { type: argon2.argon2id })

  return writeConfig('webhooks', config)
}
github ArkEcosystem / core / packages / core-commander / lib / commands / configure-webhooks / index.js View on Github external
module.exports = async () => {
  const response = await prompts(questions, { onCancel })

  let config = readConfig('webhooks')
  config.enabled = response.enabled

  if (config.enabled) {
    config.password = await argon2.hash(response.password, { type: argon2.argon2id })
  }

  return writeConfig('webhooks', config)
}
github smartcontractkit / chainlink / explorer / src / services / password.ts View on Github external
export function hash(plaintext: string): Promise {
  return argon2.hash(plaintext, { type: argon2.argon2id })
}
github ForetagInc / fullstack-ts-boilerplate / apps / api / src / app / user / user.service.ts View on Github external
public async create(user: UserCreateInput) {
    const password = await argon2.hash(user.password, {
      type: argon2.argon2id,
    });

    return await this.prisma.mutation.createUser({
      data: {
        ...user,
        password,
      },
    });
  }
}
github mentos1386 / lynx / src / modules / core / crypto / crypto.service.ts View on Github external
import { Injectable } from '@nestjs/common';
import * as argon2 from 'argon2';

@Injectable()
export class CryptoService {

  private readonly type = argon2.argon2id;

  constructor() {
  }

  /**
   * Compare hash
   * @param {string} plain
   * @param {string} hash
   * @returns {Promise}
   */
  public async compare(plain: string, hash: string): Promise {
    return await argon2.verify(hash, plain);
  }

  /**
   * Generate hash

argon2

An Argon2 library for Node

MIT
Latest version published 4 months ago

Package Health Score

82 / 100
Full package analysis