generatePasswordHash static method

String generatePasswordHash(
  1. String password,
  2. String email
)

Generates a password hash from a users password and email. This value can safely be stored in the database without the risk of exposing passwords.

Implementation

static String generatePasswordHash(String password, String email) {
  var salt = Serverpod.instance!.getPassword('email_password_salt') ??
      'serverpod password salt';
  if (AuthConfig.current.extraSaltyHash) {
    salt += ':$email';
  }
  return sha256.convert(utf8.encode(password + salt)).toString();
}