forked from menault/2026_TD2_DEV51_Qualite_Algo
rapport
This commit is contained in:
+129
-18
@@ -30,33 +30,35 @@ Groupe :
|
||||
|
||||
### J1-J6
|
||||
|
||||
- [ ] J1=1
|
||||
- [ ] J2=2+1
|
||||
- [ ] J3=7+1
|
||||
- [ ] J4=8+1
|
||||
- [ ] J5=10+1
|
||||
- [ ] J6=8+1
|
||||
- [ ] J1 = 1
|
||||
- [ ] J2 = 2 + 1 = 3
|
||||
- [ ] J3 = 7 + 1 = 8
|
||||
- [ ] J4 = 8 + 1 = 9
|
||||
- [ ] J5 = 10 + 1 = 11
|
||||
- [ ] J6 = 8 + 1 = 9
|
||||
|
||||
|
||||
### C1-C6
|
||||
|
||||
- [ ] C1=1
|
||||
- [ ] C2=2+1
|
||||
- [ ] C3=2+1
|
||||
- [ ] C4=7+1
|
||||
- [ ] C5=7+1
|
||||
- [ ] C6=10+1
|
||||
- [ ] C1 = 1
|
||||
- [ ] C2 = 2 + 1 = 3
|
||||
- [ ] C3 = 2 + 1 = 3
|
||||
- [ ] C4 = 7 + 1 = 8
|
||||
- [ ] C5 = 7 + 1 = 8
|
||||
- [ ] C6 = 10 + 1 = 11
|
||||
|
||||
|
||||
### P1-P5
|
||||
|
||||
- [ ] P1=1
|
||||
- [ ] P2=2+1
|
||||
- [ ] P3=2+1
|
||||
- [ ] P4=2+1
|
||||
- [ ] P5=13+1
|
||||
- [ ] P1 = 1
|
||||
- [ ] P2 = 2 + 1 = 3
|
||||
- [ ] P3 = 2 + 1 = 3
|
||||
- [ ] P4 = 2 + 1 = 3
|
||||
- [ ] P5 = 13 + 1 = 14
|
||||
|
||||
|
||||
### Complexité max : P5 = 14
|
||||
|
||||
|
||||
## 3. Classer
|
||||
|
||||
@@ -97,4 +99,113 @@ L'utilisation des <&&> et <||> sont nécessaire pour une compréhention plus sim
|
||||
|
||||
|
||||
|
||||
## 5. Refactoriser
|
||||
## 5. Refactoriser
|
||||
|
||||
|
||||
### P5
|
||||
|
||||
```
|
||||
def analyser_mot_de_passe(mdp, login=None):
|
||||
problemes = []
|
||||
if len(mdp) < 12:
|
||||
problemes.append("trop court")
|
||||
majuscule = minuscule = chiffre = special = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
majuscule = True
|
||||
elif c.islower():
|
||||
minuscule = True
|
||||
elif c.isdigit():
|
||||
chiffre = True
|
||||
else:
|
||||
special = True
|
||||
if not (majuscule and minuscule):
|
||||
problemes.append("mélanger majuscules et minuscules")
|
||||
if not chiffre:
|
||||
problemes.append("ajouter un chiffre")
|
||||
if not special:
|
||||
problemes.append("ajouter un caractère spécial")
|
||||
if login and login.lower() in mdp.lower():
|
||||
problemes.append("ne pas contenir le login")
|
||||
for i in range(len(mdp) - 2):
|
||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||
problemes.append("éviter 3 caractères identiques")
|
||||
break
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
```
|
||||
|
||||
Devien une fois transformé :
|
||||
|
||||
```
|
||||
def analyser_mot_de_passe(mdp, login=None):
|
||||
problemes = []
|
||||
taille_mdp(mdp, problemes)
|
||||
majuscule = caractere_majuscule
|
||||
minuscule = caractere_minuscule
|
||||
chiffre = caractere_chiffre
|
||||
special = caractere_special
|
||||
problemes(majuscule, minuscule, chiffre, special, login, mdp, problemes)
|
||||
for i in range(len(mdp) - 2):
|
||||
if mdp[i] == mdp[i + 1] == mdp[i + 2]:
|
||||
problemes.append("éviter 3 caractères identiques")
|
||||
break
|
||||
if not problemes:
|
||||
return "fort", []
|
||||
return ("moyen" if len(problemes) <= 2 else "faible"), problemes
|
||||
|
||||
|
||||
|
||||
def problemes(majuscule, minuscule, chiffre, special, login=none, mdp, problemes[]):
|
||||
if not (majuscule and minuscule):
|
||||
problemes.append("mélanger majuscules et minuscules")
|
||||
if not chiffre:
|
||||
problemes.append("ajouter un chiffre")
|
||||
if not special:
|
||||
problemes.append("ajouter un caractère spécial")
|
||||
if login and login.lower() in mdp.lower():
|
||||
problemes.append("ne pas contenir le login")
|
||||
|
||||
|
||||
|
||||
def taille_mdp(mdp, problemes[]):
|
||||
if len(mdp) < 12:
|
||||
return problemes.append("trop court")
|
||||
|
||||
|
||||
|
||||
def caractere_majuscule(mdp):
|
||||
majuscule = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
majuscule = True
|
||||
return majuscule
|
||||
|
||||
|
||||
|
||||
def caractere_minuscule(mdp):
|
||||
minuscule = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
minuscule = True
|
||||
return minuscule
|
||||
|
||||
|
||||
|
||||
def caractere_chiffre(mdp):
|
||||
chiffre = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
chiffre = True
|
||||
return chiffre
|
||||
|
||||
|
||||
|
||||
def caractere_special(mdp):
|
||||
special = False
|
||||
for c in mdp:
|
||||
if c.isupper():
|
||||
special = True
|
||||
return special
|
||||
```
|
||||
Reference in New Issue
Block a user