bcryptDigest function

BcryptHashDigest bcryptDigest(
  1. List<int> password, {
  2. List<int>? salt,
  3. BcryptVersion version = BcryptVersion.$2b,
  4. BcryptSecurity security = BcryptSecurity.good,
  5. int? nb,
})

Generate a secure password using the Bcrypt algorithm.

Bcrypt is a password hashing algorithm based on the Blowfish cipher. It uses a unique salt and a configurable cost factor to prevent rainbow table attacks and remain secure as hardware improves. Bcrypt's iterative hashing and expensive key setup phase ensure resistance to brute-force attacks.

Parameters:

  • password : The password to hash. The algorithm uses first 72 bytes, and the rest are ignored.
  • salt : An randomly generated 16-byte string.
  • nb : Number of rounds in terms of power of 2. 0 < nb < 31
  • version : The BcryptVersion to use. Default BcryptVersion.$2b
  • security : The default parameter source for nb if not provided (default is BcryptSecurity.good).

Implementation

BcryptHashDigest bcryptDigest(
  List<int> password, {
  List<int>? salt,
  BcryptVersion version = BcryptVersion.$2b,
  BcryptSecurity security = BcryptSecurity.good,
  int? nb,
}) =>
    Bcrypt(
      version: version,
      salt: salt,
      cost: nb ?? security.nb,
    ).convert(password);