calculateCharsetSize function

int calculateCharsetSize(
  1. String input
)

Calculates character set size for password entropy.

Implementation

int calculateCharsetSize(String input) {
  bool hasLower = RegExp(r'[a-z]').hasMatch(input);
  bool hasUpper = RegExp(r'[A-Z]').hasMatch(input);
  bool hasDigits = RegExp(r'[0-9]').hasMatch(input);
  bool hasSpecial = RegExp(r'[^a-zA-Z0-9]').hasMatch(input);

  int size = 0;
  if (hasLower) size += 26;
  if (hasUpper) size += 26;
  if (hasDigits) size += 10;
  if (hasSpecial) size += 32; // Common special chars

  return size;
}