2 using System.Collections.Generic;
5 using System.Text.RegularExpressions;
9 namespace sage.ew.usuario
14 public static class Password
19 public enum FortalezaPassword
50 public static int _Longitud_Minima
52 get {
return _nLongitudMinima; }
55 private static int _nLongitudMinima = 8;
60 public static int _Longitud_Maxima
62 get {
return _nLongitudMaxima; }
65 private static int _nLongitudMaxima = 20;
70 public static int _Validez_Minima
72 get {
return _nValidezMinima; }
74 private static int _nValidezMinima = 30;
79 public static int _Validez_Maxima
81 get {
return _nValidezMaxima; }
83 private static int _nValidezMaxima = 90;
88 public static bool _Requerir_Especiales
90 get {
return _lRequerir_Especiales; }
92 private static bool _lRequerir_Especiales =
false;
97 public static bool _Requerir_Numero
99 get {
return _lRequerir_Numero; }
101 private static bool _lRequerir_Numero =
false;
106 public static bool _Requerir_Mayuscula
108 get {
return _lRequerir_Mayuscula; }
110 private static bool _lRequerir_Mayuscula = Convert.ToBoolean(EW_GLOBAL._GetVariable(
"WL_STRONGPWD",
false));
117 public static FortalezaPassword _CheckPasswordStrenght(
string tcPassword)
121 int lnPuntuacion = 1;
123 if (tcPassword.Length < 1)
124 return FortalezaPassword.Blanco;
125 if (tcPassword.Length < 4)
126 return FortalezaPassword.MuyDebil;
129 if (tcPassword.Length >= 6) lnPuntuacion++;
132 if (tcPassword.Length >= 12) lnPuntuacion++;
135 if (!(tcPassword.All(c =>
char.IsLetter(c) ||
char.IsDigit(c)))) lnPuntuacion++;
139 if (tcPassword.Any(c =>
char.IsDigit(c))) lnPuntuacion++;
143 if (tcPassword.Any(c =>
char.IsUpper(c)) && tcPassword.Any(c =>
char.IsLower(c))) lnPuntuacion++;
149 if (lnPuntuacion > 5)
152 return (FortalezaPassword)lnPuntuacion;
163 public static void _GetPasswordStrenght(
string tcPassword, out
int tcValor, out
string tcDescripcion, out Color toColor)
165 Password.FortalezaPassword leFortaleza = Password._CheckPasswordStrenght(tcPassword);
168 case Password.FortalezaPassword.Blanco:
171 toColor =
Color.White;
173 case Password.FortalezaPassword.MuyDebil:
175 tcDescripcion =
"Muy débil";
178 case Password.FortalezaPassword.Debil:
180 tcDescripcion =
"Débil";
181 toColor =
Color.OrangeRed;
183 case Password.FortalezaPassword.Media:
185 tcDescripcion =
"Media";
186 toColor =
Color.Orange;
188 case Password.FortalezaPassword.Fuerte:
190 tcDescripcion =
"Fuerte";
191 toColor =
Color.LightGreen;
193 case Password.FortalezaPassword.MuyFuerte:
195 tcDescripcion =
"Muy fuerte";
196 toColor =
Color.Green;
200 tcDescripcion =
"Indeterminado";
201 toColor =
Color.White;