bcrypt function

String bcrypt(
  1. List<int> password, [
  2. String? salt
])

Generates a secure password using the Bcrypt algorithm, and returns a 60-byte encoded string containing the version, cost, salt, and password.

Parameters:

  • password : The password to hash. The algorithm uses first 72 bytes, and the rest are ignored.
  • salt : Encoded salt, e.g.: $2b$04$SQe9knOzepOVKoYXo9xTte If not provided, bcryptSalt is used to get a random one.

Note: Complete encoded string is also accepted, e.g.: $2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW

Implementation

String bcrypt(List<int> password, [String? salt]) =>
    Bcrypt.fromEncoded(fromCrypt(salt ?? bcryptSalt()))
        .convert(password)
        .encoded();